removing page scrollbars in IE8 (overflow:hidden not working)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-29 07:12:06

问题


Applying this

overflow:hidden;

to the body of my document has no effect in IE8. Any ideas why?


回答1:


It depends on whether IE8 is rendering the page in Standards or Quirks mode. For example, the following HTML will be displayed without a scrollbar:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
    <head>
        <title>test</title>
    </head>
    <body>
        <p>hello</p>
    </body>
</html>

But if you remove the doctype declaration, IE8 renders the page in Quirks mode:

<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <p>hello</p>
    </body>
</html>

You can also check this by forcing the rendering mode with the Developer Tools. Press F12 on a page, and at the end of the menu bar (for some reason...) there's a "Document Mode" setting. Toggling between Standards and Quirks here should also toggle the scrollbar.

So... you need to make your page adhere to an HTML standard! It need not be XHTML Strict, it could be HTML 4, or even XHTML Transitional if you really must.

The W3C Validator can help you with any validation errors.




回答2:


It must be something else, because I just applied overflow:hidden on this stackoverflow page's HTML element and the scrollbar disappeared.

Could you post some more css or code?

Edit: I also tried it on the body element and it also worked.. no more scrollbar.




回答3:


add this IE hack:

 max-height: none\9 


来源:https://stackoverflow.com/questions/964717/removing-page-scrollbars-in-ie8-overflowhidden-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!