突出显示时如何更改文字颜色?

时间:2015-02-21 05:43:47

标签: javascript html css

我最近创建了一个网站,并且我已经将默认突出显示的颜色从蓝色更改为番茄红色。但是我的一些文本也是番茄红色,这使得文本很难看到。如果突出显示,我应该如何更改文本颜色?

4 个答案:

答案 0 :(得分:2)

这里也适用于Firefox

body::-moz-selection { 
color: white;
background: tomato;
}
body::selection { 
color: white;
background: tomato;
}

答案 1 :(得分:0)

使用::selection伪类:

尝试以下操作
-moz-::selection,::selection{
    color:white;
    background-color:tomato;
}

当然,您可以根据自己的喜好更改颜色。请查看此处的示例:http://jsfiddle.net/8867H/65/

编辑:为了使它交叉兼容,还添加了firefox的选择器

答案 2 :(得分:0)

div {
    color: white !important;
    background: tomato !important;
}

答案 3 :(得分:0)

突出显示的文字使用text-shadow,如:



.another{
color:tomato;
	text-shadow:1px 2px 3px #858585;
	font-size:16px;
	font-weight:bold;  

}

<div class="another">
  lorem ipsum doller sit amit
  </div>
&#13;
&#13;
&#13;

相关问题