Over 15 years we helped companies reach their financial and branding goals. Beach Life Marketing is a values-driven and dedicated marketing agency.

LATEST NEWS
CONTACTS
Coding Tips

Create proportional, scaled and responsive iframes for youtube videos

Recently, I worked on a client website where it needed an embed youtube video on the product page. The embedding part wasn’t hard; the hardest part was getting the iFrame to be responsive just like the layout. One of the way that I found which worked quite well is by using the following code:

[textbox rows=”3″ width=”500″]

<div style='position: relative; width: 100%; height: 0px; padding-bottom: 60%;'>
<iframe style='position: absolute; left: 0px; top: 0px; width: 100%; height: 100%'></iframe>
</div>

[/textbox]

Hope this helps you when you are embedding video into your website using iFrame and need the iframe to be responsive.

 

References: http://flwebsites.biz/posts/proportional-responsive-iframes-youtube-videos

Author

Administrator