手机端 position:fixed;不兼容问题

jbx_jiebaixue 2014-08-15 10:02:28
写了一个底部的按钮浮动,然后页面中有文本域textarea,当选中textarea输入内容出现小键盘时,底部的浮动会跑上来,android手机也会跑上来,但是会定在小键盘上面,而ios中,浮动的位置就会错乱,在textarea上 下 中间,位置都可能发生,不知道为啥,好奇怪,请各位大侠路过的停下脚步帮忙看看,找了好久的解决办法都不行,大侠们帮帮忙吧 ,先谢谢啦!上传一张图片请大家看看,再次感谢先
...全文
12714 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
码农先生 2016-07-04
  • 打赏
  • 举报
回复
O(∩_∩)O谢谢!
引用 2 楼 save4me 的回复:
参考: Quick jQuery hack to fix position:fixed toolbars in iPhone/iPad/iPod Touch 在IPhone,IPad页面使用position: static;,如果用了jQuery,上面的文章提供了代码:

//stick the footer at the bottom of the page if we're on an iPad/iPhone due to viewport/page bugs in mobile webkit 
if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') 
{ 
     $("#footer").css("position", "static"); 
};
u014292966 2015-09-15
  • 打赏
  • 举报
回复
解决没,求解
fien 2015-08-26
  • 打赏
  • 举报
回复
引用 5 楼 jbx_jiebaixue 的回复:
@save4me 谢谢您 我找到了这个if (/ipad|iphone|mac/i.test(navigator.userAgent)){} 问题解决的算是可以了
现在遇到同样烦恼的事,头部菜单需要固定不动,但是当iphone5上面滑动页面就掉下来了,请问下 $("#footer").css("position", "static"); 这个表示是默认定位,这样能固定住footer吗?
save4me 2014-08-20
  • 打赏
  • 举报
回复
不客气,很高兴问题解决了
引用 5 楼 jbx_jiebaixue 的回复:
@save4me 谢谢您 我找到了这个if (/ipad|iphone|mac/i.test(navigator.userAgent)){} 问题解决的算是可以了
jbx_jiebaixue 2014-08-20
  • 打赏
  • 举报
回复
@save4me 谢谢您 我找到了这个if (/ipad|iphone|mac/i.test(navigator.userAgent)){} 问题解决的算是可以了
save4me 2014-08-19
  • 打赏
  • 举报
回复
你试一下下面的代码看看

//stick the footer at the bottom of the page if we're on an iPad/iPhone due to viewport/page bugs in mobile webkit 
if(/iphone|ipad|ipod/i.test(navigator.userAgent)) 
{ 
     $("#footer").css("position", "static"); 
};
引用 3 楼 jbx_jiebaixue 的回复:
save4me 你好,我试了一下,iPhone5以上没问题,可以设置,我用的是touch来测,但是bug依然存在,您知道如何判断touch吗,我用你的,改成一个if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod' || navigator.platform == 'iTouch') 呵呵,貌似不可以这样 ,应为没起作用
jbx_jiebaixue 2014-08-19
  • 打赏
  • 举报
回复
save4me 你好,我试了一下,iPhone5以上没问题,可以设置,我用的是touch来测,但是bug依然存在,您知道如何判断touch吗,我用你的,改成一个if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod' || navigator.platform == 'iTouch') 呵呵,貌似不可以这样 ,应为没起作用
save4me 2014-08-16
  • 打赏
  • 举报
回复
参考: Quick jQuery hack to fix position:fixed toolbars in iPhone/iPad/iPod Touch 在IPhone,IPad页面使用position: static;,如果用了jQuery,上面的文章提供了代码:

//stick the footer at the bottom of the page if we're on an iPad/iPhone due to viewport/page bugs in mobile webkit 
if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') 
{ 
     $("#footer").css("position", "static"); 
};

61,128

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧