gpt4 book ai didi

javascript - 为什么此 html、css 和 javascript 不适用于 iScroll4?

转载 作者:行者123 更新时间:2023-11-28 13:42:54 25 4
gpt4 key购买 nike

我正在构建一个移动网站。我需要标题为 position:fixed(但不支持移动)所以我使用 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);

如果您有任何想法,我们将不胜感激。

最佳答案

你的 loaded() 在哪里被调用?这(或类似的东西)可能会有所帮助:

<body onload="loaded()">

关于javascript - 为什么此 html、css 和 javascript 不适用于 iScroll4?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6877445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com