如何在高亮显示时更改文本颜色

How to change text color when highlighted?

本文关键字:文本 颜色 显示 高亮      更新时间:2024-02-29

我最近做了一个网站,我把默认的突出显示颜色从蓝色改为番茄红。但我的一些文本也是番茄红的,这让文本很难看到。突出显示时应如何更改文本颜色?

这里有一个也适用于Firefox的

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

使用::selection伪类尝试以下操作:

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

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

EDIT:为了使其交叉兼容,添加了firefox的选择器以及

对于突出显示的文本,使用文本阴影,如:

.another{
color:tomato;
	text-shadow:1px 2px 3px #858585;
	font-size:16px;
	font-weight:bold;  
}
<div class="another">
  lorem ipsum doller sit amit
  </div>

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