29

I came across an issue with one of our web sites:

In IE9 the page had a vertical scrollbar, but you couldn't use the mousewheel, arrow keys, pgup/pgdwn to scroll. The only way to scroll was to actually click/hold and move the scrollbar.

I removed the following from the css:

{
    overflow-x: hidden;
}

Then scrolling worked as usual. Has anyone else come across this? It seems odd as overflow-x should hide the horizontal scroll bar? Why would it effect the vertical?

I have tried this on a test page and it acts as expected. So it must be a combination of things.

4

3 回答 3

46

尝试使用以下代码片段。这应该可以解决您的问题。

body, html { 
    overflow-x: hidden; 
    overflow-y: auto;
}
于 2012-02-14T02:47:30.133 回答
17

overflow-x: hidden;
将隐藏 x 轴上超出元素的任何东西,因此不需要水平滚动条并将其删除。

overflow-y: hidden;
将隐藏 y 轴上超出元素的任何内容,因此不需要垂直滚动条并将其删除。

overflow: hidden;
将删除两个滚动条

于 2011-09-07T15:05:30.347 回答
4

我使用 iFrame 从另一个页面插入内容,但上面提到的 CSS 没有按预期工作。即使我使用 HTML 5 Doctype,我也必须使用参数 scrolling="no"

于 2015-10-26T20:30:48.693 回答