我正在建設一個移動網站。我需要的頭是位置:固定(但是不支持移動),所以我使用iScroll4,因爲它似乎是我正在尋找。出於某種原因,我無法弄清楚如何實現它。爲什麼這個html,css和javascript不能與iScroll4一起使用?
這裏是我的HTML:
<html>
<head>
<!--includes the iscroll.js file-->
</head>
<body>
<div id="header">
<!--header contents-->
</div>
<div id="wrapper">
<div id="scroller">
<!--a bunch of html that you probably don't care to see-->
</div>
</div>
這裏是我的CSS:
#scroller {
position: absolute;
}
#wrapper {
position: absolute;
width: 100%;
top: 0px;
left: 0;
overflow: auto;
}
#header {
background: #4B92DB;
border: none;
height: 175px;
opacity: 1;
position: absolute;
left: 0;
top: 0;
width: 100%;
}
這裏是我的javascript:
var myScroll;
function loaded() {
myScroll = new iScroll('wrapper');
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
如果您有任何意見,他們將大大讚賞。