CSS禁用滚动 [英] CSS Disabled scrolling

查看:520
本文介绍了CSS禁用滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我们的一个网站遇到了一个问题:

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

在IE9中,页面有一个垂直滚动条,但是你不能使用鼠标滚轮, ,pgup / pgdwn滚动。滚动的唯一方法是实际点击/按住并移动滚动条。

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.

我从css中删除了以下内容:

I removed the following from the css:

{
    overflow-x: hidden;
}

然后滚动工作像往常一样。有没有人遇到这个?看起来奇怪溢出x应该隐藏水平滚动条?为什么会影响垂直?

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.

推荐答案

尝试使用下面的代码片段。这将解决您的问题。

Try using the following code snippet. This should solve your issue.

body, html { 
    overflow-x: hidden; 
    overflow-y: auto;
}

这篇关于CSS禁用滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆