这是一个比价网站,有很多链接,其中一些链接不起作用。 我从 API 中收到的 href 为“javascript:void(0);”所以按钮什么也不做。
在页面上使用自定义 CSS,我想使用以下内容更改按钮的颜色
<a href="javascript:void(0);" class="button">Shop Now</a>
变灰。
是否可以使用自定义 CSS 更改特定 href 元素的颜色?
最佳答案
您可以使用属性选择器将属性与 [href=javascript\:void\(0\)\;]
或其某种变体完全匹配。
您可以在此处阅读有关属性选择器的更多信息:https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
a[href=javascript\:void\(0\)\;] {
color: gray;
}
<a href="javascript:void(0);" class="button">Shop Now (disabled link)</a>
<br>
<a href="#" class="button">Shop Now (normal link)</a>
关于html - CSS 更改特定 href 的按钮颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52161450/