很多网站都有这样的东西,如果你一直向上滚动,你会得到这种“弹跳”效果,就好像你的页面从浏览器窗口的顶部弹回,显示窗口顶部的空白。
同样的情况,如果你向下滚动,你会得到完全相同的“弹跳”效果。
如果您的页眉和页脚具有背景颜色,则此弹跳看起来会非常难看。
如何消除这种影响?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<header></header>
<div></div>
<footer></footer>
</body>
</html>
CSS
header {
width: 100%;
background-color: tomato;
height: 140px;
}
div {
height: 1000px;
}
footer {
width: 100%;
background-color: brown;
height: 140px;
}
最佳答案
我有类似的问题,这对我有用。
html {
overflow: hidden;
height: 100%;
}
body {
overflow: auto;
height: 100%;
}
关于html - 滚动到页面顶部和底部后如何防止空白 "bounce",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32500876/