Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do auto-width with HTML IFrame

Tags:

html

iframe

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.

like image 395
Kleyson Rios Avatar asked Apr 22 '14 11:04

Kleyson Rios


People also ask

How can I get 100 iframe width?

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.

How do I increase the width of an iframe?

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.


1 Answers

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>
like image 105
4dgaurav Avatar answered Oct 20 '22 09:10

4dgaurav