If you are using the built-in oEmbed feature of WordPress whereby pasting the URL of a YouTube video inserts the video in your post content, adding the following CSS will make the videos take up the full available width of your content with the videos proportionately sized i.e., behave responsively:

/* Make YouTube videos inserted via WordPress oEmbed full-width */

.embed-youtube {
    overflow: hidden;
    position: relative;
    max-width: 100%;
    height: auto;
    padding-bottom: 56.25%;
}

.embed-youtube iframe,
.embed-youtube object,
.embed-youtube embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

An example can be seen here.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE

Comments

For adding code blocks wrap the code in three backticks. Markdown should work.
Provide a URL of your site/webpage if something is not working.
magnifiercross
>
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: