html – CSS3 ::选择选择器在锚标签上无法正常工作

html – CSS3 ::选择选择器在锚标签上无法正常工作,第1张

概述我正在使用这样的 CSS3 :: section Selector ::selection{ color:red; background-color:pink;}::-moz-selection { color:red; background-color:pink;} 因此,当选择某个元素时,它应将其颜色更改为红色,将背景更改为粉红色. 除了Anchor标 我正在使用这样的 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.

Further information

总结

以上是内存溢出为你收集整理的html – CSS3 ::选择选择器在锚标签上无法正常工作全部内容,希望文章能够帮你解决html – CSS3 ::选择选择器在锚标签上无法正常工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1144943.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-31
下一篇2022-05-31

发表评论

登录后才能评论

评论列表(0条)

    保存