freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-html-and-html5/nest-many-elements-within-a...

3.0 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
bad87fee1348bd9aede08835 Nest Many Elements within a Single div Element 0 在单个div元素中嵌套许多元素

Description

div元素也称为除法元素,是其他元素的通用容器。 div元素可能是所有人中最常用的HTML元素。就像任何其他非自闭元素一样您可以使用<div>打开div元素,然后使用</div>其关闭到另一行。

Instructions

嵌套你的“猫喜欢的东西”和“猫讨厌的东西”列出了一个div元素。提示:尝试将您的开始div标记放在“Things cats love” p元素上方,并将结束的div标记放在结束的ol标记之后,这样两个列表都在一个div

Tests

tests:
  - text: 将<code>p</code>元素嵌套在<code>div</code>元素中。
    testString: 'assert($("div").children("p").length > 1, "Nest your <code>p</code> elements inside your <code>div</code> element.");'
  - text: 将您的<code>ul</code>元素<code>div</code>元素中。
    testString: 'assert($("div").children("ul").length > 0, "Nest your <code>ul</code> element inside your <code>div</code> element.");'
  - text: 将您的<code>ol</code>元素<code>div</code>元素中。
    testString: 'assert($("div").children("ol").length > 0, "Nest your <code>ol</code> element inside your <code>div</code> element.");'
  - text: 确保你的<code>div</code>元素有一个结束标记。
    testString: 'assert(code.match(/<\/div>/g) && code.match(/<\/div>/g).length === code.match(/<div>/g).length, "Make sure your <code>div</code> element has a closing tag.");'

Challenge Seed

<h2>CatPhotoApp</h2>
<main>
  <p>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>

  <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>

  <form action="/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>

Solution

// solution required