I'm trying
<iframe height="100%" ...>
but it still doesn't resize it. When i try the height in pixles it works.
edit: 100% seems to be working on IE but not firefox
I'm trying
<iframe height="100%" ...>
but it still doesn't resize it. When i try the height in pixles it works.
edit: 100% seems to be working on IE but not firefox
You can do it with CSS:
<iframe style="position: absolute; height: 100%; border: none"></iframe>
Be aware that this will by default place it in the upper-left corner of the page, but I guess that is what you want to achieve. You can position with the left
,right
, top
and bottom
CSS properties.
position:absolute
isn't necessary, in fact it's not a great idea unless you actually need to position it explicitly... just set the height on the parent container. –
Risk The problem with iframes not getting 100% height is not because they're unwieldy. The problem is that for them to get 100% height they need their parents to have 100% height. If one of the iframe's parents is not 100% tall the iframe won't be able to go beyond that parent's height.
So the best possible solution would be:
html, body, iframe { height: 100%; }
…given the iframe is directly under body. If the iframe has a parent between itself and the body, the iframe will still get the height of its parent. One must explicitly set the height of every parent to 100% as well (if that's what one wants).
Tested in:
Chrome 30
, Firefox 24
, Safari 6.0.5
, Opera 16
, IE 7, 8, 9 and 10
PS: I don't mean to be picky but the solution marked as correct doesn't work on Firefox 24
at the time of this writing, but worked on Chrome 30
. Haven't tested on other browsers though. I came across the error on Firefox
because the page I was testing had very little content... It could be it's my meager markup or the CSS
reset altering the output, but if I experienced this error I guess the accepted answer doesn't work in every situation.
Update 2021
@Zeni suggested this in 2015:
iframe { height: 100vh }
...and indeed it does the trick!
Careful with positioning as it can potentially break the effect. Test thoroughly, you might not need positioning depending of what you're trying to achieve.
height: 100%
does the trick. position: absolute
has nothing to do with it. –
Udella height: 100vh;
in my CSS solved the height=100%;
being ignored issue (even though I did not have a viewport
line in my HTML file). I did not need positioning ... –
Schlessinger vh
(viewport height): #5868485 –
Schlessinger The iFrame attribute does not support percent in HTML5. It only supports pixels. http://www.w3schools.com/tags/att_iframe_height.asp
© 2022 - 2024 — McMap. All rights reserved.
100%
is not correct,width
andheight
must be integer. [1] html.spec.whatwg.org/multipage/… – Inoperable.responsive-iframe { max-width: 100%; padding-top: 56.25%; position: relative; width: 100%; } .responsive-iframe iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
– Retrogradation