I am trying to use iframe to open other URLs. But for reason the width iframe is fixed in 155px.
I need to resize the width iframe to fit the whole SRC iframe.
<!DOCTYPE html>
<html>
<body>
<iframe frameborder="0" scrolling="no" height="100%" width="100%" src="http://www.gnu.org/"></iframe>
</body>
</html>
I tried width="100%", but didn't work.
To size the <iframe> , we ignore the width="560" height="315" element properties, and instead use the CSS properties width:100%;height:100%; . That's it: a full-width <iframe> with fixed aspect ratio.
Edit the width attribute. You should see the attribute "width=" after the URL in the iframe tag. Edit the width in pixels in quotations (" ") after the "width=" attribute. For example, if you want the width to be 300 pixels, you would enter "width="300px"" after the URL in the tag.
Demo
html, body {
height:100%;
width:100%;
margin:0;
}
.h_iframe iframe {
width:100%;
height:100%;
}
.h_iframe {
height: 100%;
width:100%;
}
HTML
<div class="h_iframe">
<iframe src="//www.youtube.com/embed/9KunP3sZyI0" frameborder="0" allowfullscreen></iframe>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With