gpt4 book ai didi

css - 了解特异性 : achieving desired selector outcomes without using ! 重要

转载 作者:太空狗 更新时间:2023-10-29 12:32:07 28 4
gpt4 key购买 nike

<分区>

我正在尝试理解 CSS 中的特殊性

我目前的理解是特异性与继承非常相似,但在某种程度上更具体地定义。

Mozilla Specificity Definition :

Specificity is the means by which browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied. Specificity is based on the matching rules which are composed of CSS selectors of different sorts.

当前任务是:

重构 .active a.copyright 的 CSS 声明,以便删除 !important 规则.

CSS:

.main li a {
color: #7ab2c1;
}
.active a {
color: #826c55 !important;
}
.primary p {
font-size: 12px;
}
.copyright {
font-size: 10px !important;
}

和相关的HTML:

<nav class="main">
<ul class="group">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>

[...]

<footer class="primary">
<p><a href="#">Sign up</a> for our newsletter, it's a racket!</p>
<p class="copyright">Copyright &copy; Sven's Snowshoe Emporium. All Rights Reserved.</p>
</footer>

谁能以帮助我掌握基本概念的方式指导我完成重构过程?

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