2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: bad87fee1348bd9aedf08806
|
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/cPp7VfD'
|
|
|
|
|
forumTopicId: 1
|
2021-01-13 03:31:00 +01:00
|
|
|
|
dashedName: change-the-font-size-of-an-element
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --description--
|
|
|
|
|
|
2021-01-08 11:20:48 -08:00
|
|
|
|
字体大小由 `font-size` 属性控制,如下所示:
|
2019-12-13 13:47:57 +08:00
|
|
|
|
|
|
|
|
|
```css
|
|
|
|
|
h1 {
|
|
|
|
|
font-size: 30px;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --instructions--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2021-01-08 11:20:48 -08:00
|
|
|
|
在包含 `red-text` 的类选择器的 `<style>` 声明区域的里,创建一个 `p` 元素样式规则,并设置其 `font-size` 为 `16px`。
|
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
|
|
|
|
|
2021-01-08 11:20:48 -08:00
|
|
|
|
在 `style` 样式声明区域里,`p` 元素的 `font-size` 的值应为 `16px`。请注意,浏览器和文本缩放应设置为 100%。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
```js
|
|
|
|
|
assert(code.match(/p\s*{\s*font-size\s*:\s*16\s*px\s*;\s*}/i));
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
|
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
|
|
```html
|
|
|
|
|
<style>
|
|
|
|
|
.red-text {
|
|
|
|
|
color: red;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<h2 class="red-text">CatPhotoApp</h2>
|
|
|
|
|
<main>
|
|
|
|
|
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
|
|
|
|
|
|
|
|
|
|
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<p>Things cats love:</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>cat nip</li>
|
|
|
|
|
<li>laser pointers</li>
|
|
|
|
|
<li>lasagna</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<p>Top 3 things cats hate:</p>
|
|
|
|
|
<ol>
|
|
|
|
|
<li>flea treatment</li>
|
|
|
|
|
<li>thunder</li>
|
|
|
|
|
<li>other cats</li>
|
|
|
|
|
</ol>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<form action="https://freecatphotoapp.com/submit-cat-photo">
|
|
|
|
|
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
|
|
|
|
|
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
|
|
|
|
|
<label><input type="checkbox" name="personality" checked> Loving</label>
|
|
|
|
|
<label><input type="checkbox" name="personality"> Lazy</label>
|
|
|
|
|
<label><input type="checkbox" name="personality"> Energetic</label><br>
|
|
|
|
|
<input type="text" placeholder="cat photo URL" required>
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
|
</form>
|
|
|
|
|
</main>
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --solutions--
|
2020-02-18 01:40:55 +09:00
|
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
|
```html
|
|
|
|
|
<style>
|
|
|
|
|
.red-text {
|
|
|
|
|
color: red;
|
|
|
|
|
}
|
|
|
|
|
p {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<h2 class="red-text">CatPhotoApp</h2>
|
|
|
|
|
<main>
|
|
|
|
|
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
|
|
|
|
|
|
|
|
|
|
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<p>Things cats love:</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>cat nip</li>
|
|
|
|
|
<li>laser pointers</li>
|
|
|
|
|
<li>lasagna</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<p>Top 3 things cats hate:</p>
|
|
|
|
|
<ol>
|
|
|
|
|
<li>flea treatment</li>
|
|
|
|
|
<li>thunder</li>
|
|
|
|
|
<li>other cats</li>
|
|
|
|
|
</ol>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<form action="https://freecatphotoapp.com/submit-cat-photo">
|
|
|
|
|
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
|
|
|
|
|
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
|
|
|
|
|
<label><input type="checkbox" name="personality" checked> Loving</label>
|
|
|
|
|
<label><input type="checkbox" name="personality"> Lazy</label>
|
|
|
|
|
<label><input type="checkbox" name="personality"> Energetic</label><br>
|
|
|
|
|
<input type="text" placeholder="cat photo URL" required>
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
|
</form>
|
|
|
|
|
</main>
|
|
|
|
|
```
|