2012-06-13 42 views
7

我已閱讀了一堆論壇,但沒有一個解決了我的問題。我敢肯定,它的小東西我失蹤iScroll不滾動的內容,只是彈跳回到頂部

這裏是iscroll初始化:

// make PI scroll 
piScroll2 = new iScroll('pi_scroll2'); 

這裏是我的CSS:

.pi_panel.large .content{ 
position: absolute; 
width: 963px; 
height: 616px; 
top: 65px; 
left:30px; 
background:none; 
/*background:url(../images/ISI_body.png) repeat-y;*/ 
overflow:scroll; 
    -webkit-border-radius: 0px; 

}

#FullPiWrapper 
{ 
    position:relative; 
    z-index: 1; 
    overflow:hidden; 
    top: 60px; 
    width:980px; 
    height: 610px; 
} 

.pi_panel .pi_box{ 
padding: 0px; 
margin: 20px 0px; 

}

這是我的html:

<!-- BEGIN: PI PANEL LARGE --> 
    <div class="pi_panel large"> 
    <div class="topBarPiFull"> 
       <div class="title">Full Prescribing Information</div> 
       <div class="close_button_fullpi">Close</div> 
       <div class="annotated_pi_button">Annotated PI</div> 
      </div> 
<!--   <div class="popContent"></div>--> 
      <div class="content" id="FullPiWrapper"> 

       <div id="pi_scroll2"> 


        <div class="pi_box" > 
         <img src="_globals/images/PI/pi_1.png"/> 
         <img src="_globals/images/PI/pagebreak.png" /> 
         <img src="_globals/images/PI/pi_2.png"/> 
         <img src="_globals/images/PI/pagebreak.png" /> 
         <img src="_globals/images/PI/pi_3.png"/> 
         <img src="_globals/images/PI/pagebreak.png"/> 
         <img src="_globals/images/PI/pi_4.png"/> 
         <img src="_globals/images/PI/pagebreak.png"/> 
         <img src="_globals/images/PI/pi_5.png"/> 
         <img src="_globals/images/PI/pagebreak.png" /> 
         <img src="_globals/images/PI/pi_6.png"/> 
         <img src="_globals/images/PI/pagebreak.png" /> 
         <img src="_globals/images/PI/pi_7.png"/> 
         <img src="_globals/images/PI/pagebreak.png" /> 
         <img src="_globals/images/PI/pi_8.png"/> 
         <img src="_globals/images/PI/pagebreak.png" /> 
         <img src="_globals/images/PI/pi_9.png"/> 
         <img src="_globals/images/PI/pagebreak.png" /> 
         <img src="_globals/images/PI/pi_10.png"/> 
        </div> 
       </div> 

      </div> 
    </div> 
    <!-- END: PI PANEL LARGE --> 

回答

10

問題是,當頁面第一次加載時,不能讓任何父級的div class顯示設置爲'none'。所以我設置'pi_panel large'來顯示:'block';

+2

加我1。要添加到您的答案,iscroll的容器元素必須在iscroll被初始化之前可見。我剛剛與ipad webapp上的iscroll作鬥爭,所有視圖都是動態顯示的。 –

+0

**另請參閱此處的問題與iscroll 5的答案:http://stackoverflow.com/questions/25962095/iscroll-5-not-working-when-2nd-page-should-be-scrollable – Mike6679

4

給你的包裝高度,它只是爲我工作。

.wrapper1 { 
    position:absolute; z-index:1; 
    top:250px; bottom:0px; left:3%; 
    margin-left:25px; 
    width:100%; 
    background:none; 
    overflow:auto; 
    height:100px; 
} 
1

要解決的「分區顯示無」的問題,不要在你的網格,格加載數據後下等:

  myScroll.refresh(); 
      myScroll.scrollTo(0, 0, 1000); 

凡myScroll已加載:

var myScroll = new iScroll('friendsWrapperDrug',{desktopCompatibility:true,vScroll:true,hScroll:false,hScrollbar:false,lockDirection:true});

-2

另一個適用於我的解決方案是用setTimeout包裝iScroll init函數。這將使瀏覽器在應用iScroll之前呈現元素。

+0

這是一個可怕的理念。在DOM準備好或顯示滾動條時進行操作(如果您正在動態更改可見性) –

5

確保容器的高度超過包裝紙的高度,即不要使height:100%。例如,如果包裝器包含容器,並且容器中有10個div:

如果每個div均爲100px,則包裝器可能爲150px。然後,容器必須是1000像素(不是100%!)

0
myScroll.refresh(); 
myScroll.scrollTo(0, 0, 0); 
-1

當你有一個container DIV您wrapper此解決方法是給container的高度設置爲99%出現此問題。

以下是其最終修復了這個問題對我來說是CSS:

#productsScreen{ /* my container */ 
    height: 99%; 
    z-index: 1; 
    top: 0px; 
    left: 0; 
    overflow: auto; 
} 
#productListWrapper{ 
    background:transparent; 
    position:absolute; 
    z-index:1; 
    top: 88px; 
    bottom:49px; 
    left:0; 
    width:100%; 
    overflow:auto; 
} 
#productsListScroller { 
    position:absolute; z-index:1; 
    -webkit-tap-highlight-color:rgba(0,0,0,0); 
    width:100%; 
    padding:0; 
    -webkit-box-sizing: border-box; 
    -moz-box-sizing: border-box; 
    -o-box-sizing: border-box; 
    box-sizing: border-box; 
} 

希望幫助!

+0

請投票的原因是什麼? –