为什么当我创建此 CSS 规则 `h1 {font-family: Tahoma}` 时它不起作用?

问题描述 投票:0回答:1

我有一项考试要求我“更新以下 CSS 代码,以便所有 1 级标题、2 级标题和段落元素都使用“Tahoma”字体。然后,将所有 CSS 元素的框模型重置为 border-box .”

我搜索了这个特定问题的解决方案,询问了其他同事,每个人都同意代码是正确的。

这是原来的代码:

body {
  background-color: #FFF;
  margin: 0px;
  padding: 50px 60px;
}

h1 {
  color: #007E49;
  font-size: 50px;
  font-weight: 400;
  margin: 0;
  text-align: center;
}

h2 {
  font-size: 16px;
  font-weight: 100;
  letter-spacing: 2px;
  margin: 0;
  text-align: center;
  text-transform: uppercase;
}

p {
  font-size: 16px;
  font-weight: 100;
  margin: 0;
  text-align: center;
}

#gameboard {
  position: relative;
  text-align: center;
  top: 30px;
}

.card {
  border: 2px solid #9DD1F1;
  display: inline-block;
  height: 200px;
  margin-top: 4px;
  padding: 30px auto;
  text-align: center;
  width: 215px;
}

.card:hover {
  background-color: #004E89;
  border-color: #004E89;
}

.card img {
  padding-top: 40px;
}

我尝试了这个,但系统说我“没有为 Tahoma 定义 font-family 元素”:


h1, h2, p {
  font-family: Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background-color: #FFF;
  margin: 0px;
  padding: 50px 60px;
}

h1 {
  color: #007E49;
  font-size: 50px;
  font-weight: 400;
  margin: 0;
  text-align: center;
}

h2 {
  font-size: 16px;
  font-weight: 100;
  letter-spacing: 2px;
  margin: 0;
  text-align: center;
  text-transform: uppercase;
}

p {
  font-size: 16px;
  font-weight: 100;
  margin: 0;
  text-align: center;
}

#gameboard {
  position: relative;
  text-align: center;
  top: 30px;
}

.card {
  border: 2px solid #9DD1F1;
  display: inline-block;
  height: 200px;
  margin-top: 4px;
  padding: 30px auto;
  text-align: center;
  width: 215px;
}

.card:hover {
  background-color: #004E89;
  border-color: #004E89;
}

.card img {
  padding-top: 40px;
}
css font-family
1个回答
0
投票

它确实接受了这个代码:

* {
  box-sizing: border-box;
}

body {
  background-color: #FFF;
  margin: 0px;
  padding: 50px 60px;
}

h1, h2, p {
  font-family: Tahoma, Arial, sans-serif; 
}
© www.soinside.com 2019 - 2024. All rights reserved.