为什么这个 html、css 和 javascript 不能与 iScroll4 一起使用?
我正在建立一个移动网站。我需要标题为位置:固定(但不支持移动),所以我使用 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);
如果您有任何想法,我们将不胜感激。
I am building a mobile website. I need the header to be position:fixed (but being mobile that is not supported) so I am using iScroll4 because it seems to be what I am looking for. For some reason I am not able to figure out how to implement it.
Here is my 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>
Here is my 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%;
}
And here is my Javascript:
var myScroll;
function loaded() {
myScroll = new iScroll('wrapper');
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
If you have any ideas they would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的
loaded()
在哪里被调用?这(或类似的东西)可能会有所帮助:Where's your
loaded()
being called? This (or something like it) might help:阅读 iScroll4 官方页面可能会对您有所帮助。 http://cubiq.org/iscroll-4
部分:入门。有 3 种方法可以使其工作:
所有代码都在提到的页面上。
Reading iScroll4 official page might help you. http://cubiq.org/iscroll-4
Section: Getting started. There are 3 ways to make it work:
All codes are just on the page mentioned.