2011-07-29 46 views
1

我正在建設一個移動網站。我需要的頭是位置:固定(但是不支持移動),所以我使用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); 

如果您有任何意見,他們將大大讚賞。

回答

1

你的loaded()被調用了嗎?這(或類似的東西)可能會有所幫助:

<body onload="loaded()"> 
1

閱讀iScroll4官方網頁可能會幫助你。 http://cubiq.org/iscroll-4

部分:入門。有3種方式,使其工作:

  1. onDOMContentLoaded事件來觸發iscroll
  2. onLoad事件觸發
  3. 內聯,代碼放在下面你要滾動

所有的HTML位代碼只是在提到的頁面上。

相關問題