问题
When using webview in my application, everytime I click on a link a blue box highlights the text or image. Is there anyway of removing this feature from webview?
回答1:
For accessibility reasons you shouldn't just blanket set the tap highlight color to transparent.
For elements where you want full control:
1.) Remove the tap-highlight-color
.btn {
....
-webkit-tap-highlight-color: transparent;
}
2.) Add a new :active state (in this example set a background color
.btn:active {
background-color: rgba(100, 100, 100, 1.0);
}
3.) On some elements like you may see a blue or orange border, this is just to the focus state, to remove the border:
.btn {
....
-webkit-tap-highlight-color: transparent;
outline: 0;
}
4.) Add a :focus state
.btn:focus {
background-color: rgba(200, 200, 200, 1.0);
}
5.) For bonus points add a :focus:active state
.btn:focus:active {
background-color: rgba(150, 150, 150, 1.0);
}
回答2:
Didn't have 50 reputation to post a comment.
Blow is the main content from the link in above answer.
* {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
rgba() is just like rgb(), but it takes a 4th parameter for opacity.
来源:https://stackoverflow.com/questions/10138968/android-webview-remove-blue-link-border