基于内容的CSS规则 [英] CSS rule based on content
本文介绍了基于内容的CSS规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想对包含特定字词的所有锚点应用不同的样式。它可以在纯CSS吗?
I would like to apply a different style to all anchors containing a specific word. Can it be done in pure CSS? It's ok if it's CSS3-only.
推荐答案
没有。 :包含
曾经提出,但不在CSS3选择器的当前工作草案。
No. :contains
was once proposed but is not in the current Working Draft of CSS3 Selectors.
,例如:
for (var i= document.links.length; i-->0;)
if (/\bSpecificWord\b/i.test(document.links[i].innerHTML)
document.links[i].style.color= 'red';
这篇关于基于内容的CSS规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文