移动端 常见问题整理 iOS下的 Fixed + Input 调用键盘的时候fixed无效问题解决方案
使用iScroll时,input等不能输入内容的解决方法
<script>
function allowFormsInIscroll(){
[].slice.call(document.querySelectorAll('input, select, button')).forEach(function(el){
el.addEventListener(('ontouchstart' in window)?'touchstart':'mousedown', function(e){
e.stopPropagation();
})
})
}
document.addEventListener('DOMContentLoaded', allowFormsInIscroll, false);
</script>
iscroll需要一直监听用户的touch操作,以便灵敏的做出对应效果,所以它把其余的默认事件屏蔽了。
当用iScroll时候,不能使用:focus{outline:0}伪类,否则滑动会卡
当 ipad上网页宽度超过980是,页面被截断 content="width=980 默认980;需要重新设置;
<meta name="viewport" content="width=1200, target-densitydpi=high-dpi, user-scalable=no" />
移动端浏览器中经常会出现高度100%的渲染错误,页面低端和系统自带的导航条重合了,高度的不正确我们需要重置修正它
document.documentElement.style.height = window.innerHeight + 'px';
叠加区高亮
input, textarea, button, a{-webkit-tap-highlight-color:rgba(0,0,0,0);}
button在ios上的默认样式 屏蔽输入框怪异的内阴影。
-webkit-appearance: none;border-radius: 0
IOS 等Retina屏幕 图片有点朦胧胧的感觉 根据“pixel rotio” 设置图片大小;
-webkit-background-size可以做高清图标,不过一些低版本的android只能识别background-size
iOS中,当你点击比如 input 准备输入时,虚拟键盘弹出,整个视窗的 高度 就会变为 减去键盘 的高度,加入你在底部有fixed的元素比如btn,这个元素就会跑上来。我是当focus时就把它设:absolute ;
在部分android 机型中的输入框可能多余的浮出表单,经过观察与测试发现只有input:password类型的输入框存在,那么我们只要使用input:text类型的输入框并通过样式
-webkit-text-security: disc;
隐藏输入密码从而解决。
电脑模拟器上 img border-radius:50%; overflow:hidden;没出现问题,到手机上 img四角成了方框;有时候border-radius百分比无效
border-radius:50%; overflow:hidden;
android 4.0版本以下CSS :active伪状态效果无法兼容,我们给该元素的touch系列的事件(touchstart/touchend/touchmove)绑定一个空匿名方法:
var element=document.getElementsById(”btnShare”);
element.addEventListener(‘touchstart’,function(){},false)
移动端还是PC短 如果使用fixed 元素;元素不停渲染问题;这个可以用谷歌浏览器开发者—esc -esc-rendering-show paint rectangles 查看
-webkit-transform:translateZ(0);
translateZ 还能修复部分 > 字符 问题;
父元素如果有了transform属性,子元素设置的fixed会失效。
CSS Transforms Module Level 1
不只在手机上,电脑上也一样。除了fixed元素会受影响之外,z-index(层叠上下文)值也会受影响。绝对定位元素等和包含块有关的属性都会受到影响。当然如果transform元素的display值为inline时又会有所不同。
最简单的解决方法就是transform元素内部不能有absolute、fixed元素。
textarea 文本框高度自动
//文本框高度自动
var autoTextarea = function(elem, extra, maxHeight) {
extra = extra || 0;
var isFirefox = !!document.getBoxObjectFor
|| "mozInnerScreenX" in window, isOpera = !!window.opera
&& !!window.opera.toString().indexOf("Opera"), addEvent = function(
type, callback) {
elem.addEventListener ? elem.addEventListener(type, callback,
false) : elem.attachEvent("on" + type, callback)
}, getStyle = elem.currentStyle ? function(name) {
var val = elem.currentStyle[name];
if (name === "height" && val.search(/px/i) !== 1) {
var rect = elem.getBoundingClientRect();
return rect.bottom - rect.top
- parseFloat(getStyle("paddingTop"))
- parseFloat(getStyle("paddingBottom")) + "px"
}
return val
} : function(name) {
return getComputedStyle(elem, null)[name]
}, minHeight = parseFloat(getStyle("height"));
elem.style.resize = "none";
var change = function() {
var scrollTop, height, padding = 0, style = elem.style;
if (elem._length === elem.value.length) {
return
}
elem._length = elem.value.length;
if (!isFirefox && !isOpera) {
padding = parseInt(getStyle("paddingTop"))
+ parseInt(getStyle("paddingBottom"))
}
scrollTop = document.body.scrollTop
|| document.documentElement.scrollTop;
elem.style.height = minHeight + "px";
if (elem.scrollHeight > minHeight) {
if (maxHeight && elem.scrollHeight > maxHeight) {
height = maxHeight - padding;
style.overflowY = "auto"
} else {
height = elem.scrollHeight - padding;
style.overflowY = "hidden"
}
style.height = height + extra + "px";
scrollTop += parseInt(style.height) - elem.currHeight;
document.body.scrollTop = scrollTop;
document.documentElement.scrollTop = scrollTop;
elem.currHeight = parseInt(style.height) < 100 ? parseInt(style.height)
: 100 + "px"
}
};
addEvent("propertychange", change);
addEvent("input", change);
addEvent("focus", change);
change();
};
autoTextarea(textsa);// 调用
其他新增的css3注意细节
ios Fixed + Input 失效解决办法
参考淘宝的 就好
参考网址
http://www.ghugo.com/chrome-rendering-tools-1/ 这个非常好
http://blog.bingo929.com/transform-translate3d-translatez-transition-gpu-hardware-acceleration.html
http://www.w3cfuns.com/article-1248-1.html
移动端 常见问题整理 iOS下的 Fixed + Input 调用键盘的时候fixed无效问题解决方案的更多相关文章
- iOS下的 Fixed + Input 调用键盘的时候fixed无效问题解决方案
做touchweb开发的时候,做头疼的是,电脑上面时候好的,有些手机上面也是好的,个别手机和浏览器出现问题,对于这些,只能慢慢调试,找问题. 今天说一下比较老的IOS的问题,那就是"iOS下 ...
- 【移动端debug-4】iOS下setTimeout无法触发focus事件的解决方案
开篇总结:其实目前无法解决这个bug. 这两天做项目遇到了这个case,项目需求是打开页面的时候,input元素自动弹起键盘.由于各种方面的考虑,我们希望通过setTimeout延时200毫秒让inp ...
- 移动端Web开发,ios下 input为圆角
在处理input的问题时,一般不想要input的原来的样式,一般就直接处理 border: none; outline: none; background: transparent; 这样之后,一般就 ...
- iOS下微信语音播放之切换听筒和扬声器的方法解决方案
[[UIDevice currentDevice] setProximityMonitoringEnabled:YES]; //建议在播放之前设置yes,播放结束设置NO,这个功能是开启红外感应 // ...
- IOS 表单含有input框和有position: fixed导致错位的问题
在input框聚焦失焦的时候,都调用以下js即可 setScrollTop() { let scrollTop = document.body.scrollTop + document.documen ...
- iOS通用链接(Universal Links)突然点击无效的解决方案
接上文<微信中通过页面(H5)直接打开本地app的解决方案>已经把iOS搞定并且已经正常能跑了,突然就再也用不了了... 问题描述 测试告诉我,如果从微信打开App之后,点击App右上角的 ...
- iOS 关于开发者证书:此证书的签发者无效的解决方案
备注:第二个步骤一定要进行,否则弄到吐血,还是现实签发者无效 ---------------------- 1,按照你那个链接下载,https://developer.apple.com/certif ...
- 移动端踩坑之旅-ios下fixed、软键盘相关问题总结
最近一个项目掉进了移动端的大坑,包括ios下fixed布局,h5唤起键盘等问题,作为一个B端程序员,弱项就是浏览器的兼容性和移动端的适配(毕竟我们可以要求使用chrome),还好这次让我学习了一下相关 ...
- 移动端底部fixed固定定位输入框ios下不兼容
简短记录下最近开发移动端项目碰到的小坑,产品需求做一个售后对话页面,底部固定输入框,和微信对话差不多,但是在ios下,fixed失效,输入框被虚拟键盘挡住,在安卓下是正常的. 尝试过网上说的很多方法, ...
随机推荐
- Unity3D之挥动武器产生的剑痕特效
网维教程网 观看很多其它教程 眼下已知3种方法能够做这样的剑痕特效 1.尾随特效 2.程序实现动态面来处理剑痕动画. 3.美术实现剑痕动画,直接坐在模型动画里面 (由于我不会美术所以这个忽略 嘿嘿) ...
- linux环境下的线程的创建问题
pthread_create函数用于创建一个线程 函数原型 #include<pthread.h> int pthread_create(pthread_t *restrict tidp, ...
- 对ORA-01795: 列表中的最大表达式数为 1000的处理(算法:计算数量及切割)
/** * @category * 原:strIDs in ( 100001,100002,100003,....................,110001,120001,130001,1400 ...
- RMQ之ST算法
#include <stdio.h> #include <string.h> ; int a[N]; ]; inline int min(const int &a, c ...
- KMP求字符串最小循环节
证明1: 对于一个字符串S,长度为L,如果由长度为len的字符串s(字符串s的最小循环节是其本身)循环k次构成,那么字符串s就是字符串S的最小循环节 那么字符串有个很重要的性质和KMP挂钩,即 i ...
- HT for Web嵌入QtWebKit的client解决方式
HTML5已经足够强大,但非常多应用还是须要独立桌面client的解决方式,毕竟能操作本地文件等功能还是非常多工具类软件短期内无法全然採用云方案替代. 近期Adobe公布的http://bracket ...
- uva 11427 - Expect the Expected(概率)
题目链接:uva 11427 - Expect the Expected 题目大意:你每天晚上都会玩纸牌,每天固定最多玩n盘,每盘胜利的概率为p,你是一个固执的人,每天一定要保证胜局的比例大于p才会结 ...
- 【LeetCode】【Python解决问题的方法】Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...
- oracle 优化or 更换in、exists、union all几个字眼,测试没有问题!
oracle 优化or 更换in.exists.union几个字眼.测试没有问题! 根据实际情况选择相应的语句是.假设指数,or全表扫描,in 和not in 应慎用.否则会导致全表扫描. sele ...
- 第三届蓝桥杯Java高职组决赛第三题
题目描述: 某少年宫引进了一批机器人小车.可以接受预先输入的指令,按指令行动.小车的基本动作很简单,只有3种:左转(记为L),右转(记为R),向前走若干厘米(直接记数字). 例如,我们可以对小车输入如 ...