突出显示文本CSS

时间:2012-05-12 16:01:20

标签: javascript jquery css

我想知道是否可以在JQuery中定义各种高亮类。我想要做的是突出显示选择了橙色的选择器1和用红色选择器2选择的其他标签的一些标签。

这是我的css代码:

tag.highlight { background: orange; } //class toggled for tags selected by selector1

tag.highlight_red { background: red; }//class toggled for tags selected by selector2

tag.highlight有效但tag.highlight_red不行。有什么想法吗?

谢谢

2 个答案:

答案 0 :(得分:1)

也许我错过了你想要完成的事情。您是在尝试更改元素本身的背景颜色还是仅仅选择颜色?我想,定义选择。

如果只是文字选择颜色,请尝试以下提示:http://css-tricks.com/overriding-the-default-text-selection-color-with-css/

p.red::selection {
    background: #ffb7b7;
}
p.red::-moz-selection {
    background: #ffb7b7;
}
p.blue::selection {
    background: #a8d1ff;
}
p.blue::-moz-selection {
    background: #a8d1ff;
}
p.yellow::selection {
    background: #fff2a8;
}
p.yellow::-moz-selection {
    background: #fff2a8;
}

答案 1 :(得分:0)

尝试:

tag.highlight { background-color: orange; } //class toggled for tags selected by selector1

tag.highlight_red { background-color: red !important; }//class toggled for tags selected by selector2
相关问题