Vue移动端

移动端input 无法获取焦点的问题

2016-03-30  本文已影响10461人  Scaukk

下午遇到一个问题,移动端的input都不能输入了,后来发现是

-webkit-user-select :none ;

在移动端开发中,我们有时有针对性的写一些特殊的重置,比如:

<pre>

* {
-webkit - touch - callout: none;
//-webkit-touch-callout:none; 阻止长按图片之后呼出菜单提示复制的行为

其中,-webkit-user-select :none ;会产生一些问题。
这是webkit内核浏览器下的一个bug,具体可以参考这篇文章:https://bugs.webkit.org/show_bug.cgi?id=82692

阻止了用户的选择内容行为,会导致一些“内容可编辑”标签无法正常使用,比如input、testarea。

如果网站不需要阻止用户的选择内容的行为就可以使用如下样式:

<pre>

另一种方式:

<pre>
*: not(input, textarea) {
-webkit - touch - callout: none;
-webkit - user - select: none;
}
</pre>

user-select , can cause issues in elements with contenteditable="true" ,so better to add that too .

所以,最好把它也加上。

最终的代码:

<pre>
[contenteditable = "true"], input, textarea {
-webkit-user- select: auto!important;
-khtml-user-select: auto!important;
-moz-user-select: auto!important;
-ms-user-select: auto!important;
-o-user-select: auto!important;
user-select: auto!important;
}
</pre>


本文内容大概就这么多,欢迎交流,欢迎反馈,如有错误,还请纠正,谢谢阅读。

附参考链接:
http://stackoverflow.com/questions/12812587/phonegap-styles-webkit-user-select-none-disabling-text-field

上一篇 下一篇

猜你喜欢

热点阅读