禁用蓝色背景并仅突出显示html

时间:2015-07-02 10:20:16

标签: html

我可以使用下面的代码禁用任何网页的内容选择。

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

显示文字选择的图片如下:

enter image description here

我的问题是:

  • 如何禁用蓝色背景并仅突出显示我从任何网页中选择的文字?

问题的第二部分移至ux.stackexchange

1 个答案:

答案 0 :(得分:3)

::selection CSS伪元素可以帮助您,将其应用到bodyhtml之类;

body::selection {
    background-color:transparent;
    color:#0000FF;
}

DEMO

相关问题