html - 样式 <a> 链接一次不同的样式

标签 html css

html:

<div id="content">
<p> some text </p>
<a href="#"> some link aaa </a>
<a href="#"> some other link bbb</a>
</div>

样式:

#content a 
{
color: #red;
text-decoration: underline;
}

.blue { color: #blue; }

我喜欢用 css 设计“some other link bbb”。但我喜欢另一个链接是不同的颜色。我尝试将类添加到,但没有运气..它被 a 覆盖

我该怎么做?

那为什么?

最佳答案

那里有 CSS 特异性问题。 HTML 狗有 a good tutorial对此。

来自文章:

The actual specificity of a group of nested selectors takes some calculating. Basically, you give every id selector ("#whatever") a value of 100, every class selector (".whatever") a value of 10 and every HTML selector ("whatever") a value of 1. Then you add them all up and hey presto, you have the specificity value.

关于html - 样式 <a> 链接一次不同的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7840228/

相关文章:

html - Bootstrap 4 外部内容切换器大纲

jquery - 当文本框与标签位于不同的 div 中时水平对齐文本框

css - 在任何 CSS 动画期间,SVG 图标在 chrome 中模糊/不模糊

html - 如何在所有浏览器中支持相同的边距

php - 表单数据和按钮在同一个_POST中

html - 在丰富的代码段中为 Itemscope 属性分配一个值

html - 固定侧边栏底部

css - 使用 sass @mixin 和 @content 时出现多个媒体查询问题

javascript - 使用 jquery 选择不在选项中的文本

html - 放大时使文本适合容器