Android browser - remove outline border when anchor is focused

我怕爱的太早我们不能终老 提交于 2019-12-18 11:37:45

问题


I am using on my Android app a webview which loades an external page. It has a few anchors (<a> tags). When I press on it, yellow border appears.

How can I prevent it and remove this border ?

I've tried following tricks:

// jQuery
$("a").focus(function(){
    $(this).attr("hideFocus", "hideFocus");
});

// CSS
a, :focus {
    outline: none;
}

but with no success.

Thanks !


回答1:


Set the CSS property -webkit-tap-highlight-color as follows:

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

Note: setting the color in other ways usually fails because of the way webkit renders the highlight. Depends on version/variant according to my experience.




回答2:


according to this post it's better to use

a:focus,
button:focus,
input:focus,
textarea:focus {
    outline: none;
}


来源:https://stackoverflow.com/questions/7398763/android-browser-remove-outline-border-when-anchor-is-focused

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!