It never ceases to astonish me that whenever I run into a WordPress problem or curiosity, someone out there has had the same thought and brilliantly masterminded a solution! I just ran into one such conundrum and wanted to share the answer with you all.

I am designing an Ecommerce website, and of course in this day and age it needs to be fully responsive.  The theme itself is working like a dream and seems to be adapting remarkably well through all the testing. The only thing that was not responsive was the embedded YouTube video. However I found this little quick fix on a fellow WordPress designers’ blog and it worked like a dream! Give it a try yourself:

First you will need to add the following to your style sheet:

.video-container {
    positionrelative;
    padding-bottom56.25%;
    padding-top30pxheight0overflowhidden;
}
.video-container iframe,
.video-container object,
.video-container embed {
    positionabsolute;
    top0;
    left0;
    width100%;
    height100%;
}

 

Next, edit add some HTML around your embed code:

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

Check out this video on your phone, tablet, and computer to see it in action!

 

To check out the original blog and website designer this was posted by, visit http://avexdesigns.com/responsive-youtube-embed/