How to make auto width with HTML IFrame

I am trying to use iframes to open other urls. But for the reason the iframe width is fixed at 155px.

I need to resize the iframe width to fit all iframe SRCs.

<!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 did not work.

+4
source share
3 answers

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>
+5
source

You should just do it with CSS

eg.

style="width:100%"

I just pasted your HTML into the fiddle. And he works as intended. Do you have any css overlapping width or inside a container of 155 pixels wide, where do you use it?

It works for me at least.

0
source

:

    <iframe 
        src="http://www.gnu.org/" 
        frameborder="0"
        scrolling="no" 
        style="overflow:hidden;height:100%;width:100%" 
        height="100%" 
     width="100%"></iframe>
0

Source: https://habr.com/ru/post/1537493/


All Articles