2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: bad87fee1348bd9aede08835
|
|
|
|
|
challengeType: 0
|
2019-12-26 20:05:59 +08:00
|
|
|
|
videoUrl: 'https://scrimba.com/p/pVMPUv/cNW4kC3'
|
|
|
|
|
forumTopicId: 18246
|
2020-10-01 17:54:21 +02:00
|
|
|
|
title: 元素嵌套
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
2019-12-26 20:05:59 +08:00
|
|
|
|
<section id='description'>
|
|
|
|
|
<code>div</code>元素,也叫 Content Division Element(内容划分元素)元素,是一个包裹其他元素的通用容器。
|
|
|
|
|
它也是 HTML 中出现频率最高的元素。
|
|
|
|
|
和其他普通元素一样,你可以用<code><div></code>来标记一个<code>div</code>元素的开始,用<code></div></code>来标记一个<code>div</code>元素的结束。
|
|
|
|
|
</section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
## Instructions
|
2019-12-26 20:05:59 +08:00
|
|
|
|
<section id='instructions'>
|
|
|
|
|
把无序列表、有序列表和段落都嵌套进同一个<code>div</code>元素。
|
|
|
|
|
提示:你可以在第一个<code><p></code>之前插入<code>div</code>开始标记,在<code></ol></code>之后插入<code>div</code>结束标记,这样,所有的列表都位于<code>div</code>之内。
|
|
|
|
|
</section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
2019-12-26 20:05:59 +08:00
|
|
|
|
- text: '把所有的<code>p</code>元素嵌入<code>div</code>元素中。'
|
|
|
|
|
testString: assert($("div").children("p").length > 1);
|
|
|
|
|
- text: '把<code>ul</code>元素嵌入<code>div</code>元素中。'
|
|
|
|
|
testString: assert($("div").children("ul").length > 0);
|
|
|
|
|
- text: '把<code>ol</code>元素嵌入<code>div</code>元素中。'
|
|
|
|
|
testString: assert($("div").children("ol").length > 0);
|
|
|
|
|
- text: '确保<code>div</code>元素有结束标记。'
|
|
|
|
|
testString: assert(code.match(/<\/div>/g) && code.match(/<\/div>/g).length === code.match(/<div>/g).length);
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='html-seed'>
|
|
|
|
|
|
|
|
|
|
```html
|
|
|
|
|
<h2>CatPhotoApp</h2>
|
|
|
|
|
<main>
|
2019-12-26 20:05:59 +08:00
|
|
|
|
<p>点击查看更多<a href="#">猫咪图片</a>。</p>
|
|
|
|
|
|
|
|
|
|
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="一只仰卧着的萌猫"></a>
|
|
|
|
|
|
|
|
|
|
<p>猫咪最喜欢的三件东西:</p>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
<ul>
|
2019-12-26 20:05:59 +08:00
|
|
|
|
<li>猫薄荷</li>
|
|
|
|
|
<li>激光笔</li>
|
|
|
|
|
<li>千层饼</li>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
</ul>
|
2019-12-26 20:05:59 +08:00
|
|
|
|
<p>猫咪最讨厌的三件东西:</p>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
<ol>
|
2019-12-26 20:05:59 +08:00
|
|
|
|
<li>跳蚤</li>
|
|
|
|
|
<li>打雷</li>
|
|
|
|
|
<li>同类</li>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
</ol>
|
2019-12-26 20:05:59 +08:00
|
|
|
|
|
2020-07-15 02:55:06 -07:00
|
|
|
|
<form action="https://freecatphotoapp.com/submit-cat-photo">
|
2019-12-26 20:05:59 +08:00
|
|
|
|
<label><input type="radio" name="indoor-outdoor">室内</label>
|
|
|
|
|
<label><input type="radio" name="indoor-outdoor">室外</label><br>
|
|
|
|
|
<label><input type="checkbox" name="personality">忠诚</label>
|
|
|
|
|
<label><input type="checkbox" name="personality">懒惰</label>
|
|
|
|
|
<label><input type="checkbox" name="personality">积极</label><br>
|
|
|
|
|
<input type="text" placeholder="猫咪图片地址" required>
|
|
|
|
|
<button type="submit">提交</button>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
</form>
|
|
|
|
|
</main>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
</section>
|
2019-12-26 20:05:59 +08:00
|
|
|
|
|