<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="/static/css/reset.css">
<link rel="stylesheet" href="/static/css/all.css">
<title>書城首頁(yè)</title>
<style type="text/css">
#root {
width: 100%;
height: 100%;
position: fixed;
}
.container-warp {
height: 100%;
overflow: hidden;
position: relative;
}
.container-scroll {
position: absolute;
top: 45px;
bottom: 0px;
left: 0px;
right: 0px;
overflow-y: scroll;
}
</style>
</head>
<body>
<div id="root">
<div class="container-warp">
<% include include/header.html %>
<div class="container-scroll">
<% include include/index-top.html %>
<% include include/index-hot.html %>
<% include include/index-recommend.html %>
<% include include/index-female.html %>
<% include include/index-male.html %>
<% include include/index-free.html %>
<% include include/index-bottom.html %>
</div>
</div>
</div>
<script src="/static/script/vue.min.js"></script>
<script src="/static/script/zepto.min.js"></script>
<script src="/static/script/pages/index.js"></script>
</body>
</html>
三種解決方案
1适袜、body加position:fixed;width:100%;height:100%场躯。
2、給要滾動(dòng)的元素添加一個(gè)父級(jí)盼产,設(shè)定高度,overflow:auto勺馆;
3戏售、html,body{height:100%;overflow:hidden}
建議使用第三種侨核,可以把overflow:hidden作為一個(gè)單獨(dú)的隱藏類,更方便控制灌灾。