我正在使用这样的
CSS3 :: section Selector
::selection{ color:red; background-color:pink; } ::-moz-selection { color:red; background-color:pink; }
因此,当选择某个元素时,它应将其颜色更改为红色,将背景更改为粉红色.
除了Anchor标签< a>之外,它可以按预期工作.
选择锚文本时,它会将样式应用于链接文本,但不会应用于锚文本下方的行.
JSFiddle:http://jsfiddle.net/GcBT2/1/
那么我们怎样才能将样式应用到下划线呢?
PS:浏览器测试:chrome 31和firefox 25.0.1
解决方法
注意
per MDN
Only a small subset of CSS properties can be used in a rule using
::selection in its selector: color,background,background-color and
text-shadow. Note that,in particular,background-image is ignored,
like any other property.
链接上的行是文本修饰的一部分,伪选择器不会考虑这一行.你最好的选择可能是使用它删除它
a{ text-decoration:none; }
您可能还想注意:
Though this pseudo-element was in drafts of CSS Selectors Level 3,it
was removed during the Candidate Recommendation phase (07001)The ::selection pseudo-element currently isn’t in any CSS module on
the standard track. It should not be used in production environments.