Horizontal scrollbar appears only in IE7 even with overflow:hidden being set

感情迁移 提交于 2019-12-10 13:58:32

问题


I'm banging my head on this one.

I have a disturbing horizontal scrollbar that appears only when browsing my site in IE7:
http://www.regia.it

I have tried and tried to stop this from happening by using overflow:hidden on my divs but for some reason I just can't seem to find what is causing the problem.

Any help is greatly appreciated.


回答1:


This does seem odd. I am assuming you don't mind if the page is not horizontally scrollable even on small screens, since you have tried to use:

body{overflow-x: hidden;}

In which case if you apply it to html rather than body it should do the trick:

html{overflow-x: hidden;}

I wouldn't really want to implement this long term, but if you are looking for a quick fix this should be ok as a temporary measure until you can work out what is going wrong. I would also put it in a conditional comment so as not to ruin the experience for the majority of people on modern browsers.

<!--[if IE 7]>
    Link to alternate style sheet
    OR
    <style> /*CSS in here*/ </style>
<![endif]-->

EDIT : I have found the cause of the issue, so there is no need to use the above workaround. As I had suspected the issue was related to absolute and relative positioning.

You just need to remove position:relative from .grid_2 and .grid_12 and the scrollbar will disappear.




回答2:


I came across this vexing issue too. I had a table in a div, and these were inside an outer div. When I removed the style to make the inner div width:100%, my 'IE7 only' scrollbar situation disappeared.

Hopefully that is somewhat helpful.



来源:https://stackoverflow.com/questions/7435328/horizontal-scrollbar-appears-only-in-ie7-even-with-overflowhidden-being-set

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