我有一个文本 div,我希望能够在不显示垂直滚动条的情况下滚动它。我已经按照这个但无济于事,文本滚动但是滚动条仍然可见。 Hide scroll bar, but while still being able to scroll
#activity_parent {
height: 100%;
width: 100%;
overflow: hidden;
}
#activity_child {
width: 100%;
height: 100%;
overflow-y: scroll;
padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
}
<div id="activity_parent">
<div id="activity_child">
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
good<br/>bye.
</div>
</div>
最佳答案
您使用的是什么浏览器,因为在测试您的代码后,此处未显示垂直滚动条。
最好还是将 CSS 放在样式标签中,如下所示
<html>
<style>
#activity_parent {
height: 100%;
width: 100%;
overflow: hidden;
}
#activity_child {
width: 100%;
height: 100%;
overflow-y: scroll;
padding-right: 17px; /* Increase/decrease this value for cross-browser
compatibility */
}
</style>
<body>
<div id="activity_parent">
<div id="activity_child">
<!-- you content goes here -->
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
hello<br/>I<br/>am<br/>here<br/>
good<br/>bye.
</div>
</div>
</body>
</html>
关于html - 无法隐藏垂直滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45900542/