我在 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,它占用空间最小(与使用成熟的框架相比):
这是来自 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/