2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: 587d781b367417b2b2512abb
|
2020-12-16 00:37:30 -07:00
|
|
|
|
title: 使用 hr 标签创建水平线
|
2018-10-10 18:03:03 -04:00
|
|
|
|
challengeType: 0
|
2020-02-11 15:46:34 +08:00
|
|
|
|
videoUrl: 'https://scrimba.com/c/c3bR8t7'
|
|
|
|
|
forumTopicId: 301049
|
2021-01-13 03:31:00 +01:00
|
|
|
|
dashedName: create-a-horizontal-line-using-the-hr-element
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --description--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
术语:Horizontal Rule => hr => 水平线。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2021-01-08 11:20:48 -08:00
|
|
|
|
你可以用 `hr` 标签来创建一条宽度撑满父元素的水平线。这种水平分割线一般用来表示内容主题的改变,或在视觉上将文档分隔成几个部分。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
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
|
|
|
|
在卡片标题元素 `h4` 下方添加一个 `hr` 标签。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2021-01-08 11:20:48 -08:00
|
|
|
|
**注意:**HTML 中的 `hr` 是自闭合标签,所以我们不需要为它添加结束标签。
|
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
|
|
|
|
应存在一个 `hr` 标签。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
```js
|
|
|
|
|
assert($('hr').length == 1);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
`hr` 标签应该在标题和段落之间。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
```js
|
|
|
|
|
assert(code.match(/<\/h4>\s*?<hr(>|\s*?\/>)\s*?<p>/gi));
|
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>
|
|
|
|
|
h4 {
|
|
|
|
|
text-align: center;
|
|
|
|
|
height: 25px;
|
|
|
|
|
}
|
|
|
|
|
p {
|
|
|
|
|
text-align: justify;
|
|
|
|
|
}
|
|
|
|
|
.links {
|
|
|
|
|
text-align: left;
|
|
|
|
|
color: black;
|
|
|
|
|
}
|
|
|
|
|
.fullCard {
|
|
|
|
|
width: 245px;
|
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
margin: 10px 5px;
|
|
|
|
|
padding: 4px;
|
|
|
|
|
}
|
|
|
|
|
.cardContent {
|
|
|
|
|
padding: 10px;
|
|
|
|
|
}
|
|
|
|
|
.cardText {
|
|
|
|
|
margin-bottom: 30px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<div class="fullCard">
|
|
|
|
|
<div class="cardContent">
|
|
|
|
|
<div class="cardText">
|
|
|
|
|
<h4><s>Google</s>Alphabet</h4>
|
|
|
|
|
|
|
|
|
|
<p><em>Google was founded by Larry Page and Sergey Brin while they were <u>Ph.D. students</u> at <strong>Stanford University</strong>.</em></p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="cardLinks">
|
|
|
|
|
<a href="https://en.wikipedia.org/wiki/Larry_Page" target="_blank" class="links">Larry Page</a><br><br>
|
|
|
|
|
<a href="https://en.wikipedia.org/wiki/Sergey_Brin" target="_blank" class="links">Sergey Brin</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --solutions--
|
|
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
|
```html
|
|
|
|
|
<style>
|
|
|
|
|
h4 {
|
|
|
|
|
text-align: center;
|
|
|
|
|
height: 25px;
|
|
|
|
|
}
|
|
|
|
|
p {
|
|
|
|
|
text-align: justify;
|
|
|
|
|
}
|
|
|
|
|
.links {
|
|
|
|
|
text-align: left;
|
|
|
|
|
color: black;
|
|
|
|
|
}
|
|
|
|
|
.fullCard {
|
|
|
|
|
width: 245px;
|
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
margin: 10px 5px;
|
|
|
|
|
padding: 4px;
|
|
|
|
|
}
|
|
|
|
|
.cardContent {
|
|
|
|
|
padding: 10px;
|
|
|
|
|
}
|
|
|
|
|
.cardText {
|
|
|
|
|
margin-bottom: 30px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<div class="fullCard">
|
|
|
|
|
<div class="cardContent">
|
|
|
|
|
<div class="cardText">
|
|
|
|
|
<h4><s>Google</s>Alphabet</h4>
|
|
|
|
|
<hr>
|
|
|
|
|
<p><em>Google was founded by Larry Page and Sergey Brin while they were <u>Ph.D. students</u> at <strong>Stanford University</strong>.</em></p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="cardLinks">
|
|
|
|
|
<a href="https://en.wikipedia.org/wiki/Larry_Page" target="_blank" class="links">Larry Page</a><br><br>
|
|
|
|
|
<a href="https://en.wikipedia.org/wiki/Sergey_Brin" target="_blank" class="links">Sergey Brin</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
```
|