禁用焦点上的橙色轮廓突出显示

发布于 2024-10-20 06:49:32 字数 1135 浏览 7 评论 0原文

我正在使用 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"

没有任何效果。

更新:我已经对此进行了更多故障排除,迄今为止发现:

  1. outline 属性仅适用于 Chrome,不适用于 Android 浏览器。

  2. -webkit-tap-highlight-color 属性实际上在 Android 浏览器上有效,但在 Chrome 上无效。它会禁用焦点和点击时的突出显示。

  3. -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:

  1. The outline property works only on Chrome, not on the Android browser.

  2. 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.

  3. The -webkit-focus-ring-color property does not seem to work on either browser.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(16

‖放下 2024-10-27 06:49:33

我已经尝试过这个并且工作正常:-

HTML:-

<a class="html5logo"  href="javascript:void(0);"  ontouchstart="return true;"></a>

css

.html5logo {
  display: block;
  width: 128px;
  height: 128px;
  background: url(/img/html5-badge-128.png) no-repeat;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  -webkit-tap-highlight-color: transparent; /* For some Androids */
}
.html5logo:active {
  -webkit-transform: scale3d(0.9, 0.9, 1);
}

I have tried this one and worked fine :-

HTML:-

<a class="html5logo"  href="javascript:void(0);"  ontouchstart="return true;"></a>

css

.html5logo {
  display: block;
  width: 128px;
  height: 128px;
  background: url(/img/html5-badge-128.png) no-repeat;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  -webkit-tap-highlight-color: transparent; /* For some Androids */
}
.html5logo:active {
  -webkit-transform: scale3d(0.9, 0.9, 1);
}
∞琼窗梦回ˉ 2024-10-27 06:49:33

这不仅适用于点击,也适用于悬停:

button, button:hover, li:hover, a:hover , li , a , *:hover, * {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}

This will work not only for taps, but hover as well:

button, button:hover, li:hover, a:hover , li , a , *:hover, * {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}
尤怨 2024-10-27 06:49:33
<EditText
            android:id="@+id/edittext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"  
            android:background="@android:drawable/editbox_background_normal"                 

 />
<EditText
            android:id="@+id/edittext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"  
            android:background="@android:drawable/editbox_background_normal"                 

 />
甜点 2024-10-27 06:49:33

如果设计不使用轮廓,这应该可以完成工作:

*, *::active, *::focus {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0)!important;
    -webkit-focus-ring-color: rgba(0, 0, 0, 0)!important;
    outline: none!important;
}

If the design doesn't use outlines, this should do the job:

*, *::active, *::focus {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0)!important;
    -webkit-focus-ring-color: rgba(0, 0, 0, 0)!important;
    outline: none!important;
}
一影成城 2024-10-27 06:49:33

尝试以下禁用边框轮廓的代码

大纲:无!重要;

Try following code that disable border outline

outline: none !important;

看透却不说透 2024-10-27 06:49:32

尝试:

-webkit-tap-highlight-color: rgba(255, 255, 255, 0); 
-webkit-tap-highlight-color: transparent;  // i.e. Nexus5/Chrome and Kindle Fire HD 7''

Try:

-webkit-tap-highlight-color: rgba(255, 255, 255, 0); 
-webkit-tap-highlight-color: transparent;  // i.e. Nexus5/Chrome and Kindle Fire HD 7''
多情癖 2024-10-27 06:49:32

适用于 Android 默认、Android Chrome 和 iOS Safari 100%

* {
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0) !important; 
    -webkit-focus-ring-color: rgba(255, 255, 255, 0) !important; 
    outline: none !important;
} 

Work on Android Default, Android Chrome and iOS Safari 100%

* {
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0) !important; 
    -webkit-focus-ring-color: rgba(255, 255, 255, 0) !important; 
    outline: none !important;
} 
心头的小情儿 2024-10-27 06:49:32
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);  
} 

在你的 css 文件中。
这对我有用!

* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);  
} 

in your css file.
It worked for me !

如果没结果 2024-10-27 06:49:32

删除 Android 输入焦点上的橙色框

textarea:focus, input:focus{
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0);    
    -webkit-user-modify: read-write-plaintext-only;
}

tap-highlight-color 对于大多数版本

user-modify 对于 4.0.4

Remove the orange box on input focus for Androids

textarea:focus, input:focus{
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0);    
    -webkit-user-modify: read-write-plaintext-only;
}

tap-highlight-color for most versions

user-modify for 4.0.4

泪眸﹌ 2024-10-27 06:49:32

尝试聚焦线

body, textarea:focus, input:focus{
    outline: none;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
}

Try for Focus Line

body, textarea:focus, input:focus{
    outline: none;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
}
万人眼中万个我 2024-10-27 06:49:32

请注意,使用此 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.

别再吹冷风 2024-10-27 06:49:32

为了确保 tap-highlight-color 属性覆盖适合您,请首先考虑以下事项:

不工作:
-webkit-user-modify:仅读写纯文本;
// 有时点击元素时会触发原生键盘弹出

.class:active, .class:focus { -webkit-tap-highlight-color: rgba(0,0,0,0); }
// 如果为状态定义则不起作用

工作:
.class { -webkit-tap-highlight-color: rgba(0,0,0,0); }

此案例适用于 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:

Not working:
-webkit-user-modify: read-write-plaintext-only;
// It sometimes triggers the native keyboard to popup when clicking the element

.class:active, .class:focus { -webkit-tap-highlight-color: rgba(0,0,0,0); }
// It's not working if defined for states

Working:
.class { -webkit-tap-highlight-color: rgba(0,0,0,0); }

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.

嘿嘿嘿 2024-10-27 06:49:32

在 CSS 文件中使用以下代码

  * {
     -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    :focus {
        outline: 0;
        border:none;
        color: rgba(0, 0, 0, 0);
    }

这对我有用。我希望它对你有用。

Use the below code in CSS file

  * {
     -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    :focus {
        outline: 0;
        border:none;
        color: rgba(0, 0, 0, 0);
    }

It's work for me. I hope it work for you.

何以笙箫默 2024-10-27 06:49:32

我只是想分享我的经验。我并没有真正让它发挥作用,我想避免缓慢的 css-*。我的解决方案是下载旧版 Eric Meyer 的 Reset CSS v2.0 (http://meyerweb.com /eric/tools/css/reset/)并将其添加到我的phonegap项目中。然后我补充道:

-webkit-tap-highlight-color: rgba(0, 0, 0, 0);   /** Disable orange highlight */

根据我的经验,这是一种更快的方法,但它也是一种减少奇怪错误的方法。 tap-highlight、-webkit-user-modify: read-write-plaintext-only 和禁用文本突出显示等功能的组合给我们带来了很多麻烦。最糟糕的情况之一是键盘输入突然停止工作并减慢键盘可视化速度。

完成 CSS 重置并禁用橙色突出显示:

/**
 * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
 * http://cssreset.com
 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);   /** Disable orange highlight */
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

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:

-webkit-tap-highlight-color: rgba(0, 0, 0, 0);   /** Disable orange highlight */

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:

/**
 * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
 * http://cssreset.com
 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);   /** Disable orange highlight */
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}
悲歌长辞 2024-10-27 06:49:32

这在 Ionic 中对我有用,只需放入 CSS 文件来覆盖

:focus {
    outline-width: 0px;
}

This work for me in Ionic, just put in CSS file to overwrite

:focus {
    outline-width: 0px;
}
以酷 2024-10-27 06:49:32

这对我的图像地图区域链接不起作用,唯一有效的解决方案是通过捕获 ontouchend 事件并通过在处理程序上返回 false 来防止默认浏览器行为来使用 javascript。

使用 jQuery:

$("map area").on("touchend", function() {
   return false;
});

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:

$("map area").on("touchend", function() {
   return false;
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文