我不知道为什么我的样式表没有覆盖normalize.css
的边距值。
在 html 中,样式表链接的顺序是正确的:
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/2may.css">
在normalize.css中,h1的边距设置如下:
h1 {
font-size: 2em;
margin: 0.67em 0;
}
使用我的样式表,我试图覆盖它:
*{
box-sizing: border-box;
color: #ddd;
padding: 0;
border: 0;
margin: 0;
text-decoration: none;
}
最佳答案
因为h1
比*
更精确
您应该阅读this
示例:
* /* a=0 b=0 c=0 -> specificity = 0 */
LI /* a=0 b=0 c=1 -> specificity = 1 */
UL LI /* a=0 b=0 c=2 -> specificity = 2 */
UL OL+LI /* a=0 b=0 c=3 -> specificity = 3 */
H1 + *[REL=up] /* a=0 b=1 c=1 -> specificity = 11 */
UL OL LI.red /* a=0 b=1 c=3 -> specificity = 13 */
LI.red.level /* a=0 b=2 c=1 -> specificity = 21 */
#x34y /* a=1 b=0 c=0 -> specificity = 100 */
#s12:not(FOO) /* a=1 b=0 c=1 -> specificity = 101 */
根据您的情况,只需添加:
margin: 0;
您的 h1 声明。
关于css - 我的样式表未覆盖 Normalize.css <h1> 边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50136899/