I see alot of questions about 100% height iFrames but noone seems to have the exact same problem as I do.
What I want to do is to have an iFrame that covers the entire viewport, with no scrollbars, without setting overflow: hidden on the body.
I get a 5px bottom margin to my iFrame that won't go away with css, and it causes a vertical scroolbar. The standard advice seems to be to set overflow: hidden on the body, but that's not really solving the problem, and it's not enough for me.
Here's a super simple jsFiddle example. (notice the double vertical scrollbars)
This behaviour is the same in Chrome 15, IE9 and FF9 for me.
It's not the iframe that produces the scrollbar, it's the whitespace after it
If you don't want to see it, use
edit: Turns out the problem persists if you remove the whitespace, but the solution is the same. Iframes are rendered as inline elements by default (iframe = 'inline frame'), and thus have a line-height which causes the issue.
Alternatively, you may want to try
iframe { display: block; }
or a combination of both solutions.To prevent the scroll bar try this:
CSS:
HTML:
The .bbox style prevents sub divs from growing. .Vat is necessary for IE and Firefox. An alternative for .vat is: display:block. Or display:inline-block + vertical-alignment:top .brd is for demonstration purposes.
Update:
working example in
chrome 16.0.*
,firefox 10.*
(apparently ie9 acts up and displays a scrollbar either way -- either a disabled one if the height is set to 99% or a active one that can't scroll if height is 100%):place the following in a html file and open it (don't know what jsfiddle is doing different, but it doesn't work the same way)
To summarize it:
This is due to the inline character of iframe as pointed out in the first post.
Not seeing a vertical scroll-bar outside of jsFiddle with this:
EDIT: Here's a snippet from under the Elements tabs of what gets selected when I inspect the white-space in Chrome.