I am attempting to apply CSS to scale an iFrame by setting width: 100%
, while also having the height adjust proportionally to the width.
This resizing technique works perfectly with an <img>
tag.
Both the image and the iFrame have their width and height specified in the HTML.
Here are some examples:
<html>
<style>
#a{ width: 500px; }
img{ width: 100%; height: auto }
</style>
<body>
<div id="a">
<img src="http://lorempixel.com/200/150/" width="200" height="150" />
</div>
</body>
While this method works well for images, I am looking to achieve the same effect with iFrames:
<html>
<style>
#a{ width: 900px; background: grey;}
iframe{ width: 100%; height: auto }
</style>
<body>
<div id="a">
<iframe width="560" height="315" src="http://www.youtube.com/embed/RksyMaJiD8Y" frameborder="0" allowfullscreen></iframe>
</div>
</body>
Although the iFrame expands to be 100% wide, it does not adjust its height proportionally like the image does.