单个CSS命令可以限制多少行

  • 本文关键字:多少 CSS 命令 单个 css
  • 更新时间 :
  • 英文 :


好吧,所以我想为学校做作业,我终于开始在CSS上工作。

我的问题是我输入的代码,对于ID #articleheader不适用,我能想到的唯一原因是在关闭行之前存在四个规则。

#articleheader {
  font-size: 18px;
  font-weight: normal;
  letter-spacing: 7px;
  text-align: center;
}
<header id="articleheader">
  <h1>Bike the Mountains Tour</h1>
</header>

有帮助吗?

h1具有自己的尺寸和重量样式,即使您没有专门设置它们,默认情况下也具有其风格。为h1设置它们:

#articleheader h1 {
    ...

就您要执行的操作以及何时将代码放入HTML文档时,一切似乎都很好。如果Matt提供的解决方案仍然不起作用,我建议您需要检查是否将CSS文件正确链接到外部样式表或启动页面,请确保正确包裹在标签上。

<html>
<head>
<style>
#articleheader {
        font-size: 18px;
        font-weight: normal;
        letter-spacing: 7px;
        text-align: center;
}
</style>
</head>
<body
    <header id="articleheader">
     <h1>Bike the Mountains Tour</h1>
    </header>
</body>
</html>

enter code here您应该使用H1应用ID =" ArtendHeader"标签,而不是标题。,尽管在标题中使用ID标签没有错,但是结果不会如预期的。

这是将ID应用于H1

时的结果

这是将ID应用于标题

时的结果
<header>
     <h1 id="articleheader">Bike the Mountains Tour</h1>
</header>

CSS代码没有错

当在H1和Header上应用相同的ID标签时,证明了在H1上应用的ID标签的优先级,但显示了早期图像(带有ID)中所示的结果。

<html>
    <head>
      <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
     <header id="articleheader" >
        <h1 id="articleheader" >Bike the Mountains Tour</h1>
     </header>
    </body>
  </html>   

最新更新