css - 我的样式表未覆盖 Normalize.css <h1> 边距

标签 css

我不知道为什么我的样式表没有覆盖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/

相关文章:

Jquery设置不透明度问题

javascript - 如何防止 Bootstrap 导航栏按钮堆叠

css - 当输入在标签标签内时,将单选输入样式设置为按钮

javascript - 如何为计算器 HTML 设置按钮样式

css - 使用 Bootstrap 均匀分开单选按钮

css - sencha cmd 4 和 sencha touch 2.3 在 app.json 中添加 css

html - 更改选项中文本的颜色

html - 具有固定列和流动列以及清晰 float 的布局

html - 为什么使用 this.src 时此图像不会在鼠标悬停时发生变化?

html - 如何使用CSS将图像设为 "tint"