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

问题描述 投票:0回答:1

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

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

有没有办法选择不以特定模式开头的链接,即所有不以“/ tutorials_”开头的链接。我知道有一个不是选择器,但我无法弄清楚如何将它用于此目的。

css
1个回答
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/

© www.soinside.com 2019 - 2024. All rights reserved.