WP Decoder

How to Make YouTube Videos Responsive in WordPress

I just found this great article that uses only CSS to make videos responsive: http://www.wpstuffs.com/youtube-videos-responsive-wordpress/

Here’s the gist:

Add this to your style.css file:

.video-container {
        position: relative;
        padding-bottom: 56.25%;
        padding-top: 30px;
        height: 0;
        overflow: hidden;
}

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

.entry-content img, 
.entry-content iframe, 
.entry-content object, 
.entry-content embed {
        max-width: 100%;
}

Then, where ever you have a video, surround it with a “video-container” div. For example:

<div class="video-container"> 
<iframe width="560" height="315" src="http://www.youtube.com/embed/S95J5BowMmk" frameborder="0" allowfullscreen></iframe> 
</div>

It worked great for me. I hope it will help you too!