html - 如何在 PHONE GAP 中为 Android 设备修复此 STICKY 页脚?

标签 html css cordova media-queries cordova-2.0.0

我在 Phone Gap 工作。我修复了一个页脚,这适用于少数设备,但不适用于少数设备。

页脚的 HTML 代码

 <div id="footer" style="background-image:url(img/bottom_bar.png);" class="footer">
    <div id="footer_text" class="footer_text">footer</div>
    <div id="info" class="info noSelect"><img src="img/info.png"/></div>
 </div>

页脚的 CSS

.footer
{
   width:100%;  position:fixed; bottom:0; font-size:11px; color:#FFFFFF; text-align:center; height:30px;
}
.footer_text
{
    text-indent:1%; float:left; text-align:center;  width:75%;  margin-top:2%;
}   

对于少数设备,它位于屏幕底部...尽管内容溢出,对于少数设备,它会随着内容移动。

编辑:

根据 Filippos Karapetis 先生的建议,我尝试实现 iscroll4

我使用了来自 here 的这个 javascript

并初始化滚动条

    document.addEventListener("deviceready", onDeviceReady, false);
    function scroll() 
    {
        myScroll = new IScroll('.wrapper', { mouseWheel:true });
    }
    -----
            -----
          function onDeviceReady() 
    {   
        scroll();
                ----
                ----

页脚 CSS

.footer
{
   width:100%;  position:fixed; bottom:0; font-size:11px; color:#FFFFFF; text-align:center; height:30px;
}
.footer_text
{
    text-indent:1%; float:left; text-align:center;  width:75%;  margin-top:2%;
}   

问题是它只滚动一次

最佳答案

固定位置元素在某些移动设备中存在错误。这是他们浏览器中的错误/缺失功能。查看此页面,其中列出了固定位置元素与多种不同移动设备的兼容性:

https://bradfrost.com/blog/post/fixed-position/

该页面还包括基于 Javascript 的解决方案,通过覆盖浏览器的默认滚动行为来解决这些设备中的这个错误。例如,在 jQuery Mobile 中,固定元素会在页面滚动时淡出,然后在滚动结束时淡入。

解决您的问题的最直接的解决方案是 iScroll 4,它占用空间最小(与使用成熟的框架相比):

http://cubiq.org/iscroll-4

这是来自 iScroll 4 页面的一个小概述:

iScroll 4 is a complete rewrite of the original iScroll code. The script development began because mobile webkit (on iPhone, iPad, Android) does not provide a native way to scroll content inside a fixed width/height element. This unfortunate situation prevents any web-app to have a position:absolute header and/or footer and a scrolling central area for contents.

While latest Android revisions are supporting this functionality (although support is not optimal), Apple seems reluctant to add one finger scrolling to divs.

关于html - 如何在 PHONE GAP 中为 Android 设备修复此 STICKY 页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16957930/

相关文章:

java - 将 HTML 符号转换为 Java 符号

javascript - 具有访问值的自定义 jQuery 缓动函数

javascript - 如何从远程 JSON 文件仅收集特定数据

html - 设置 img 边框以推送列表中的下一个图像

javascript - 如何在动态生成的元素上应用样式

css - 类、相邻兄弟和伪选择器不能一起工作

html - 什么时候 CSS 的顺序很重要?

javascript - 在 phonegap 中禁用方向更改动画

ios - Phonegap CLI 5.1.1 --变量未显示在plugin.xml中

debugging - 有没有办法在不同平台上测试 phonegap 构建应用程序