选择不以特定模式开头的href

时间:2018-03-02 02:35:40

标签: css

我知道我可以使用css选择以特定模式开头的链接,例如

a[href^="tutorials_"] { text-color: red; }

有没有办法选择不以特定模式开头的链接,即所有不以" / tutorials _"开头的链接。我知道那里没有选择器,但我无法弄清楚如何将它用于此目的。

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

a:not([href^="tutorials_"]) { 
  color: red; 
}
<a href="tutorials_1">Link 1</a>
<a href="not_tutorials_1">Not link 1</a>
<a href="not_tutorials_1">Not link 1</a>

这里有很好的参考:https://css-tricks.com/almanac/selectors/n/not/

相关问题