我尝试创建一个隐藏滚动条的页面,但您仍然可以滚动或点击链接向下滚动。我可以隐藏滚动条但我无法滚动,只留下100%的页面。 HTML
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="container">
<div id="content1">Hello</div>
<div id="content2">Hello2</div>
<div id="content3">Hello3</div>
<div id="content4">Hello4</div>
<div id="links">
<a href="#content1" class="contentLink">link 1</a> |
<a href="#content2" class="contentLink">link 2</a> |
<a href="#content3" class="contentLink">link 3</a> |
<a href="#content4" class="contentLink">link 4</a>
</div>
</div>
</body>
</html>
的CSS
#container, #content1, #content2, #content3, #content4 {
position: absolute;
width: 100%;
height: 100%;
top: 0; left: 0;
z-index: 1;
overflow:hidden}
#content1 { top: 0%; background: yellow; }
#content2 { top: 100%; background: red; }
#content3 { top: 200%; background: orange; }
#content4 { top: 300%; background: purple; }
#links {
position: fixed;
bottom: 10px; left: 10px;
z-index: 2;}
答案 0 :(得分:1)
只需设置滚动条的样式,而不是元素。
::-webkit-scrollbar,::-webkit-scrollbar-button,::-webkit-scrollbar-track,::-webkit-scrollbar-track-piece,::-webkit-scrollbar-thumb,::-webkit-scrollbar-corner,::-webkit-resizer
{opacity:0; }