--- id: bad87fee1348bd9aedf08808 title: Specify How Fonts Should Degrade challengeType: 0 videoUrl: '' localeTitle: 指定字体应如何降级 --- ## Description
所有浏览器都有几种默认字体。这些通用字体系列包括monospaceserifsans-serif当一个字体不可用时,您可以告诉浏览器“降级”为另一种字体。例如,如果您希望元素使用Helvetica字体,但在Helvetica不可用时降级为sans-serif字体,则将按如下方式指定:
p {
font-family:Helvetica,sans-serif;
}
通用字体系列名称不区分大小写。此外,它们不需要引号,因为它们是CSS关键字。
## Instructions
首先,将monospace字体应用于h2元素,以便它现在有两种字体 - Lobstermonospace字体。在上一个挑战中,您使用link标记导入了Lobster字体。现在注释掉谷歌字体导入的Lobster字体(使用之前学过的HTML评论),以便它不再可用。注意你的h2元素如何降级为monospace字体。 注意
如果您的计算机上安装了Lobster字体,您将看不到降级,因为您的浏览器能够找到该字体。
## Tests
```yml tests: - text: 你的h2元素应该使用字体Lobster 。 testString: 'assert($("h2").css("font-family").match(/^"?lobster/i), "Your h2 element should use the font Lobster.");' - text: 当Lobster不可用时,你的h2元素会降级为monospace字体。 testString: 'assert(/\s*h2\s*\{\s*font-family\:\s*(\"|")?Lobster(\"|")?,\s*monospace\s*;\s*\}/gi.test(code), "Your h2 element should degrade to the font monospace when Lobster is not available.");' - text: 通过在其前面放置<!--来注释您对Google的Lobster字体的调用。 testString: 'assert(new RegExp("", "gi").test(code), "Be sure to close your comment by adding -->.");' ```
## Challenge Seed
```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

  • cat nip
  • laser pointers
  • lasagna

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


```
## Solution
```js // solution required ```