安卓2.3 + PhoneGap的固定定位不工作工作、PhoneGap

2023-09-04 10:13:21 作者:宁可过错也不错过

在我的PhoneGap的应用程序,我试图让出一个固定的页脚和头,这实际上是在Android 4.0的伟大工程。但在Android 2.3,即使它看起来还好,当我开始滚动页眉和页脚doesen't保持固定可言,与滚动沿着去。

On my Phonegap app i'm trying to make out a fixed footer and header, that actually in Android 4.0 works great. But on Android 2.3 even if it looks okay, when I start to scroll the header and footer doesen't stay fixed at all, going along with the scrolling.

相关code如下所示:

The relevant code follows below:

HTML:

<div class="container-fluid no-padding">
<div id="header">

</div>  
<div class="wrapper">
    <div id="main-content"></div>
    <div id="push"></div>
</div>
<div id="footer" class="main-footer">

</div>

CSS:

html,body,.container-fluid {
    height: 100%;
    font-family: Helvetica !important;
}

#wrapper {
    min-height: 100%;
    height: auto !important;
    height: 100%;
    padding-left: 10px;
    padding-right: 10px;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: -20px; /* the bottom margin is the negative value of the footer's height */
    overflow: scroll;
}

#footer, #push {
    height: 20px; /* .push must be the same height as .footer */
    width: 100%;
}

#footer {
    position: fixed;
    z-index: 10; /* Defect #9 */
    margin: 0;
    bottom:0px;
}

#header {
    position: fixed;
    z-index: 5;
    height: 40px;
    background-color: #FFFFFF;
    width: 100%;
    top: 0px !important;
}

#main-content {
    margin-top: 45px;
}

.main-footer {
    background-color: #cf2129;
    color: #FFFFFF;
}

如果它是相关的,我没有使用jQuery Mobile的(即我发现awnsers的大部分涉及到),但Twitter的引导,而不是。

If it is relevant, I'm not using jQuery Mobile (that most part of the awnsers I found relate to), but Twitter Bootstrap instead.

任何指导,是值得欢迎的。

Any guidance is welcome

推荐答案

我发现了,

只需添加用户可扩展= 0元​​标记视

Just add "user-scalable=0" to the meta viewport tag.

网页设计师习惯使用CSS的位置固定元素的窗口。但是固定的,在手机浏览器的土地,用于固定定位的支持远不如普遍的方式是更古怪

Web designers are used to fixing elements to the window using CSS’s position: fixed, however, in the land of mobile browsers, support for fixed positioning is far less universal and is way more quirky.

来源:http://bradfrostweb.com/blog/mobile/fixed-position/

它会告诉你需要知道的关于固定元素和移动浏览器的一切:)

It tells everything you need to know about fixed elements and mobile browsers :)