禁用焦点上的橙色轮廓突出显示
我正在使用 jQuery、jqTouch 和 Phonegap 编写一个应用程序,并且遇到了一个持续存在的问题,当用户使用软键盘上的 Go 按钮提交表单时会出现该问题。
虽然使用 $('#input_element_id').focus()
可以很容易地将光标移动到适当的表单输入元素,但橙色轮廓突出显示始终返回到表单上的最后一个输入元素。形式。 (使用表单提交按钮提交表单时,突出显示不会显示。)
我需要的是找到一种方法来完全禁用橙色突出显示,或者使其移动到与光标相同的输入元素。
到目前为止,我已尝试将以下内容添加到我的 CSS 中:
.class_id:focus {
outline: none;
}
这适用于 Chrome,但不适用于模拟器或我的手机。我还尝试编辑 jqTouch theme.css
来读取:
ul li input[type="text"] {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); and
-webkit-focus-ring-color: rgba(0, 0, 0, 0);
}
没有效果。 我还尝试了 AndroidManifest.xml
文件中的以下每项添加:
android:imeOptions="actionNone"
android:imeOptions="actionSend|flagNoEnterAction"
android:imeOptions="actionGo|flagNoEnterAction"
没有任何效果。
更新:我已经对此进行了更多故障排除,迄今为止发现:
outline 属性仅适用于 Chrome,不适用于 Android 浏览器。
-webkit-tap-highlight-color
属性实际上在 Android 浏览器上有效,但在 Chrome 上无效。它会禁用焦点和点击时的突出显示。-webkit-focus-ring-color
属性似乎不适用于任一浏览器。
I am coding an app using jQuery, jqTouch and phonegap and have run across a persistent problem which arises when a user submits a form using the Go button on the soft keyboard.
Although it is easy to get the cursor to move to the appropriate form input element by using $('#input_element_id').focus()
, the orange outline highlight always returns to the last input element on the form. (The highlight does not show up when the form is submitted using the form submit button.)
What I need is to find a way either to disable the orange highlight completely or else make it move to the same input element as the cursor.
So far, I have tried adding the following to my CSS:
.class_id:focus {
outline: none;
}
This works in Chrome but not on the emulator or on my phone. I have also tried editing the jqTouch theme.css
to read:
ul li input[type="text"] {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); and
-webkit-focus-ring-color: rgba(0, 0, 0, 0);
}
With no effect.
I have also tried each of the following additions to the AndroidManifest.xml
file:
android:imeOptions="actionNone"
android:imeOptions="actionSend|flagNoEnterAction"
android:imeOptions="actionGo|flagNoEnterAction"
None of which have any effect.
Update: I have done some more troubleshooting with this and to date have found:
The outline property works only on Chrome, not on the Android browser.
The
-webkit-tap-highlight-color
property does in fact work on the Android browser, though not on Chrome. It disables the highlight on focus as well as on tapping.The
-webkit-focus-ring-color
property does not seem to work on either browser.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
我已经尝试过这个并且工作正常:-
HTML:-
css
I have tried this one and worked fine :-
HTML:-
css
这不仅适用于点击,也适用于悬停:
This will work not only for taps, but hover as well:
如果设计不使用轮廓,这应该可以完成工作:
If the design doesn't use outlines, this should do the job:
尝试以下禁用边框轮廓的代码
Try following code that disable border outline
尝试:
Try:
适用于 Android 默认、Android Chrome 和 iOS Safari 100%
Work on Android Default, Android Chrome and iOS Safari 100%
在你的 css 文件中。
这对我有用!
in your css file.
It worked for me !
删除 Android 输入焦点上的橙色框
tap-highlight-color 对于大多数版本
user-modify 对于 4.0.4
Remove the orange box on input focus for Androids
tap-highlight-color for most versions
user-modify for 4.0.4
尝试聚焦线
Try for Focus Line
请注意,使用此 CSS
-webkit-user-modify: read-write-plaintext-only;
将消除那个可怕的突出显示“错误” - 但它可能会破坏您的设备提供特定键盘的能力。对于在 Samsung Tab 2 上运行 Android 4.0.3 的我们来说,我们无法再使用数字键盘。即使使用 type='number' &/或 type='tel' 。非常令人沮丧!顺便说一句,设置点击突出显示颜色并不能解决该设备和操作系统配置的此问题。我们正在运行 Android 版 Safari。
Be aware that using this CSS
-webkit-user-modify: read-write-plaintext-only;
WILL remove that horrible highlight 'bug' - BUT it may kill your devices ability to provide a specific keyboard. For us running Android 4.0.3 on a Samsung Tab 2, we could no longer get the numeric keyboard. Even using type='number' &/or type='tel' . Very frustrating!BTW, setting tap highlight colour did nothing to resolve this issue for this device and OS config. We are running Safari for android.
为了确保
tap-highlight-color
属性覆盖适合您,请首先考虑以下事项:此案例适用于 Android v2.3 到 v4.x,甚至在 PhongeGap 应用程序中也是如此。我在运行 Android 2.3.3 的 Galaxy Y、运行 Android 4.2.2 的 Nexus 4 和运行 Android 4.1.2 的 Galaxy Note 2 上进行了测试。因此不要仅为元素本身的状态定义它。
To make sure the
tap-highlight-color
property overriding works for you, consider these things first:This case works for Android from v2.3 to v4.x even in a PhongeGap application. I tested it on Galaxy Y with Android 2.3.3, on Nexus 4 with Android 4.2.2 and on Galaxy Note 2 with Android 4.1.2. So don't define it for states only for the element itself.
在 CSS 文件中使用以下代码
这对我有用。我希望它对你有用。
Use the below code in CSS file
It's work for me. I hope it work for you.
我只是想分享我的经验。我并没有真正让它发挥作用,我想避免缓慢的 css-*。我的解决方案是下载旧版 Eric Meyer 的 Reset CSS v2.0 (http://meyerweb.com /eric/tools/css/reset/)并将其添加到我的phonegap项目中。然后我补充道:
根据我的经验,这是一种更快的方法,但它也是一种减少奇怪错误的方法。 tap-highlight、-webkit-user-modify: read-write-plaintext-only 和禁用文本突出显示等功能的组合给我们带来了很多麻烦。最糟糕的情况之一是键盘输入突然停止工作并减慢键盘可视化速度。
完成 CSS 重置并禁用橙色突出显示:
I just wanted to share my experience. I didn't really get this to work, and I wanted to avoid the slow css-*. My solution was to download good old Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/) and add this one to my phonegap project. I then added:
In my experience this is a faster approach to the *, but it is also an approach to less weird bugs. Combination of tap-highlight, -webkit-user-modify: read-write-plaintext-only and disabling of for example text highlighting have provided us with a lot of headaces. One of the worst being that suddenly keyboard input stops working and slow keyboard visualization.
Complete CSS-reset with the orange highlight disabled:
这在 Ionic 中对我有用,只需放入 CSS 文件来覆盖
This work for me in Ionic, just put in CSS file to overwrite
这对我的图像地图区域链接不起作用,唯一有效的解决方案是通过捕获 ontouchend 事件并通过在处理程序上返回 false 来防止默认浏览器行为来使用 javascript。
使用 jQuery:
This didn't work for me on Image Map Area links, the only working solution was to use javascript by capturing the ontouchend event and preventing default browser behavior by returning false on the handler.
with jQuery: