我可以使用下面运行良好的代码禁用任何网页的内容选择。
<div
style="-moz-user-select: none; -webkit-user-select: none; -ms-user-select:none; user-select:none;-o-user-select:none;"
unselectable="on"
onselectstart="return false;"
onmousedown="return false;">
Cannot select me
</div>
显示文本选择的图片如下:
我的问题是:
- 如何禁用蓝色背景并仅突出显示我从任何网页中选择的文本?
问题的第二部分移至ux.stackexchange .
最佳答案
::selection CSS 伪元素会帮助你,将它应用于 body
或 html
之类的;
body::selection {
background-color:transparent;
color:#0000FF;
}
关于html - 禁用蓝色背景并仅突出显示 html 中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31181923/