gpt4 book ai didi

css - 如何通过定位 anchor 标记内的类来更改 anchor 标记中的颜色或文本?

转载 作者:太空宇宙 更新时间:2023-11-03 20:19:18 25 4
gpt4 key购买 nike

有人可以解释为什么会发生以下情况吗:

<a href="#" class="test">Test</a>

<style type="text/css">
.test {
border: thin solid blue;
color: red;
}
</style>

这只会创建边框,但不会在使用类时将文本变为红色。

但是,这可以在使用 id 时将文本变为红色:

<a href="#" id="test">Test</a>

<style type="text/css">
#test {
border: thin solid blue;
color: red;
}
</style>

为什么类不改变文本颜色,而使用 id 却有效?

谢谢!

最佳答案

用这个

demo here

 <a href="#" class="test">Test</a>

<style type="text/css">
a.test {
border: thin solid blue;
color: red;
}
</style>

关于css - 如何通过定位 anchor 标记内的类来更改 anchor 标记中的颜色或文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13870009/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com