提问者:小点点

所有不是“。time”的元素都应该有字体开放的sans,400px,颜色:#333333,行高1.6


我为我的网站编写了下面的代码,但是当我这样写的时候,网站似乎理解了代码中“时间”部分的“courier new”位,但是它似乎不理解不是时间组件的字体的命令。它似乎不处理代码的任何正文{margin-bottom:16px;font-family:Open sans;font-weight:400;font-size:16px;line-height:1.6;color:#333333;}位。(我基本上是试图获得所有内容的字体,不是“时间”,打开无人,400px,颜色:#333333,行高1.6.)我下面的代码有问题吗?救命啊!谢谢。

<html>
<head>
<style> 
body .time {
font-family: "Courier New" } body {margin-bottom: 16px; font-family: Open Sans; font-weight: 400; 
font-size: 16px; line-height: 1.6; color: #333333; } 
</style>
</head>
<body>

<p>Weekdays <span class="time">10:00~18:00</span></p>
<p>Saturdays <span class="time">10:00~13:30</span></p>
<p>(we are closed on holidays.)</p>

</body>
</html>

共2个答案

匿名用户

我建议使用“所有”选择器*,并将其组合如下:

* {
  font-family: "Open Sans"; 
  font-weight: 400; 
  font-size: 16px; 
  line-height: 1.6; 
  color: #333333; 
} 
.time {
  font-family: "Courier New";
} 

还要注意CSS规则的顺序:.time规则中的font-family在以这种方式使用时覆盖*规则的font-family。

注意:我不建议在*规则中添加margin设置--这将影响所有默认浏览器边距,这可能是不需要的。

匿名用户

答:

<html>
<head>
<style> 
.time {
font-family: "Courier New" ;
  color:green;
  } 
body {margin-bottom: 16px; 
  font-family: Open Sans; 
  font-weight: 400; 
font-size: 16px; 
  line-height: 1.6; 
  color: #333333; 
  } 
</style>
</head>
<body>

<p>Weekdays <span class="time">10:00~18:00</span></p>
<p>Saturdays <span class="time">10:00~13:30</span></p>
<p>(we are closed on holidays.)</p>

</body>
</html>