2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: 587d781c367417b2b2512ac2
|
2020-12-16 00:37:30 -07:00
|
|
|
title: 设置多个标题元素的 font-size
|
2018-10-10 18:03:03 -04:00
|
|
|
challengeType: 0
|
2020-02-11 15:46:34 +08:00
|
|
|
videoUrl: 'https://scrimba.com/c/cPpQNT3'
|
|
|
|
forumTopicId: 301067
|
2021-01-13 03:31:00 +01:00
|
|
|
dashedName: set-the-font-size-for-multiple-heading-elements
|
2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --description--
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
`font-size` 属性用来指定元素内文字的大小。 我们可以为多个元素添加这个规则,让页面内不同元素的文字大小得以统一。 在本挑战里,你需要设置从 `h1` 到 `h6` 的文字大小。
|
2020-12-16 00:37:30 -07:00
|
|
|
|
2022-03-31 22:31:59 +05:30
|
|
|
# --instructions--
|
|
|
|
|
|
|
|
<p>在 <code>style</code> 标签中, 对各元素的 <code>font-size</code> 进行如下设置:</p>
|
2021-01-08 11:20:48 -08:00
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li>将 <code>h1</code> 标签的文字大小设为 68px。</li>
|
|
|
|
<li>将 <code>h2</code> 标签的文字大小设为 52px。</li>
|
|
|
|
<li>将 <code>h3</code> 标签的文字大小设为 40px</li>
|
|
|
|
<li>将 <code>h4</code> 标签的文字大小设为 32px</li>
|
|
|
|
<li>将 <code>h5</code> 标签的文字大小设为 21px</li>
|
|
|
|
<li>将 <code>h6</code> 标签的文字大小设为 14px</li>
|
|
|
|
</ul>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --hints--
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
`h1` 标签的 `font-size` 属性值应为 68px。
|
2020-12-16 00:37:30 -07:00
|
|
|
|
|
|
|
```js
|
2021-08-26 21:51:26 -07:00
|
|
|
const fontSizeOfh1 = new __helpers.CSSHelp(document).getStyle('h1')?.getPropertyValue('font-size');
|
|
|
|
assert(fontSizeOfh1 === '68px');
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
`h2` 标签的 `font-size` 属性值应为 52px。
|
2020-12-16 00:37:30 -07:00
|
|
|
|
|
|
|
```js
|
2021-08-26 21:51:26 -07:00
|
|
|
const fontSizeOfh2 = new __helpers.CSSHelp(document).getStyle('h2')?.getPropertyValue('font-size');
|
|
|
|
assert(fontSizeOfh2 === '52px');
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
`h3` 标签的 `font-size` 属性值应为 40px。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
2021-08-26 21:51:26 -07:00
|
|
|
const fontSizeOfh3 = new __helpers.CSSHelp(document).getStyle('h3')?.getPropertyValue('font-size');
|
|
|
|
assert(fontSizeOfh3 === '40px');
|
2020-12-16 00:37:30 -07:00
|
|
|
```
|
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
`h4` 标签的 `font-size` 属性值应为 32px。
|
2020-12-16 00:37:30 -07:00
|
|
|
|
|
|
|
```js
|
2021-08-26 21:51:26 -07:00
|
|
|
const fontSizeOfh4 = new __helpers.CSSHelp(document).getStyle('h4')?.getPropertyValue('font-size');
|
|
|
|
assert(fontSizeOfh4 === '32px');
|
2020-12-16 00:37:30 -07:00
|
|
|
```
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
`h5` 标签的 `font-size` 属性值应为 21px。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
2021-08-26 21:51:26 -07:00
|
|
|
const fontSizeOfh5 = new __helpers.CSSHelp(document).getStyle('h5')?.getPropertyValue('font-size');
|
|
|
|
assert(fontSizeOfh5 === '21px');
|
2020-12-16 00:37:30 -07:00
|
|
|
```
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-02-06 04:42:36 +00:00
|
|
|
`h6` 标签的 `font-size` 属性值应为 14px。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
2021-08-26 21:51:26 -07:00
|
|
|
const fontSizeOfh6 = new __helpers.CSSHelp(document).getStyle('h6')?.getPropertyValue('font-size');
|
|
|
|
assert(fontSizeOfh6 === '14px');
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
2020-02-11 15:46:34 +08:00
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```html
|
|
|
|
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|
|
|
|
<h1>This is h1 text</h1>
|
|
|
|
<h2>This is h2 text</h2>
|
|
|
|
<h3>This is h3 text</h3>
|
|
|
|
<h4>This is h4 text</h4>
|
|
|
|
<h5>This is h5 text</h5>
|
|
|
|
<h6>This is h6 text</h6>
|
|
|
|
```
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --solutions--
|
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
```html
|
|
|
|
<style>
|
|
|
|
h1 {
|
|
|
|
font-size: 68px;
|
|
|
|
}
|
|
|
|
h2 {
|
|
|
|
font-size: 52px;
|
|
|
|
}
|
|
|
|
h3 {
|
|
|
|
font-size: 40px;
|
|
|
|
}
|
|
|
|
h4 {
|
|
|
|
font-size: 32px;
|
|
|
|
}
|
|
|
|
h5 {
|
|
|
|
font-size: 21px;
|
|
|
|
}
|
|
|
|
h6 {
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<h1>This is h1 text</h1>
|
|
|
|
<h2>This is h2 text</h2>
|
|
|
|
<h3>This is h3 text</h3>
|
|
|
|
<h4>This is h4 text</h4>
|
|
|
|
<h5>This is h5 text</h5>
|
|
|
|
<h6>This is h6 text</h6>
|
|
|
|
```
|