gpt4 book ai didi

css - 正文设置为 overflow-y :hidden but page is still scrollable in Chrome

转载 作者:技术小花猫 更新时间:2023-10-29 10:10:41 25 4
gpt4 key购买 nike

我在 Chrome 中遇到 overflow-y 属性问题。即使我已将其设置为隐藏,我仍然可以使用鼠标滚轮滚动页面。

这是我的代码:

html,
body {
overflow-y: hidden;
}

#content {
position: absolute;
width: 100%;
}

.step {
position: relative;
height: 500px;
margin-bottom: 500px;
}
<body>
<div id="content">
<div class="step">this is the 1st step</div>
<div class="step">this is the 2nd step</div>
<div class="step">this is the 3rd step</div>
</div>
</body>

有人知道如何阻止 Chrome 中的垂直滚动吗?

谢谢!

最佳答案

将 body 高度和 html 设置为 100% 应该可以解决问题。如果没有定义的高度,您的内容就不会溢出,因此您将无法获得所需的行为。

html, body {
overflow-y:hidden;
height:100%;
}

关于css - 正文设置为 overflow-y :hidden but page is still scrollable in Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19236349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com