Disabled scroll bar (grayed out), except in IE7

2019-09-03 04:20发布

问题:

I have an overlay and to disable scrolling while the scroll bar is still visible (grayed out), I used:

CSS

html.noscroll {
    position: fixed;
    overflow-y: scroll;
    width: 100%;
}

It works properly in IE8 and higher, but in IE7 the scroll bar is still enabled, and I can still scroll through the page.

Does anybody have an idea how I can solve this problem?

回答1:

overflow:scroll makes IE displaying the scrollbar in all cases, even if it is not needed. That's what you want to do ?

IE6 & 7 are known to have scrolls issues when coupled with 'position:relative' or 'width:100%' and margins.

Try with

width: 80%;

If scrolls are correctly greyed, you probably have a margin/padding issue. If it changed nothing, try changing the position.