2012-03-15 23 views
4

我使用JQM 1.1-RC1中可用的新的固定頭jQueryMobile 1.1-RC1固定報頭導致頁面滾動時不需要

的頁面看起來像這樣

<div data-theme="a" data-role="page" data-title="Home" id="home_page" > 
    <div data-role="header" data-theme="b" data-position="fixed" data-tap-toggle="false"> 
     <h1>Home</h1> 
    </div> 
    <div data-role="content" id="categories_content"> 
     <ul data-role="listview" data-theme="a" id="categories_list"> 
      <li>something</li> 
      <li>something else</li> 
     </ul> 
    </div> 
    <div data-role="footer" data-position="fixed" data-tap-toggle="false"><h1>Home</h1></div> 
</div> 

我的問題是,該頁面在無需滾動時會滾動。名單很短,不會低於頁腳。

有沒有人遇到過這個問題,如果是的話,你是如何克服它?

下面是該問題上的jsfiddle:jsFiddle

在此先感謝。

回答

1

這似乎是一個與jQuery Mobile的錯誤。將填充添加到.ui-page元素以解釋頁眉和頁腳,但頁面加載或瀏覽器重新調整大小時高度未正確更新。你可以用一個黑客位的解決這個問題:

//bind to the resize event for the window element 
​$(window)​.on('resize', function() { 

    //set a timeout to allow jQuery Mobile to update the element before we correct the value 
    setTimeout(function() { 

     //change the height of the current page to get rid of the scroll bar 
     $.mobile.activePage.css('minHeight', '-=85px'); 
    }, 50); 

//trigger a resize event onload 
}).trigger('resize')​;​​ 

更新

我開始爲jQuery Mobile的Github上的bug報告來解決這個問題:https://github.com/jquery/jquery-mobile/issues/3825

+0

我用的這個變體,它工作。謝謝 – 2012-03-15 19:55:11

相關問題