2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: bad87fee1348bd9aede08807
|
2020-12-16 00:37:30 -07:00
|
|
|
title: 设置元素的字体家族
|
2018-10-10 18:03:03 -04:00
|
|
|
challengeType: 0
|
2019-12-13 13:47:57 +08:00
|
|
|
videoUrl: 'https://scrimba.com/c/c3bvpCg'
|
|
|
|
forumTopicId: 18278
|
2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --description--
|
|
|
|
|
|
|
|
通过`font-family`属性,可以设置元素里面的字体样式。
|
|
|
|
|
|
|
|
如果你想设置`h2`元素的字体为`sans-serif`,你可以用以下的 CSS 规则:
|
2019-12-13 13:47:57 +08:00
|
|
|
|
|
|
|
```css
|
|
|
|
h2 {
|
|
|
|
font-family: sans-serif;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --instructions--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
确保`p`元素使用`monospace`字体。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
`p`元素应该使用`monospace`字体。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
|
|
|
assert(
|
|
|
|
$('p')
|
|
|
|
.not('.red-text')
|
|
|
|
.css('font-family')
|
|
|
|
.match(/monospace/i)
|
|
|
|
);
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --solutions--
|
2019-12-13 13:47:57 +08:00
|
|
|
|