iFrame 100% height causes vertical scrollbar

前端 未结 5 1197
Happy的楠姐
Happy的楠姐 2020-12-14 18:12

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 enti

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 18:59

    It's not the iframe that produces the scrollbar, it's the whitespace after it

        
        
    
    

    If you don't want to see it, use

    * { line-height: 0; }
    

    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.

提交回复
热议问题