Files
freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-css/adjust-the-margin-of-an-element.chinese.md
2020-02-11 15:42:42 +09:00

1.8 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, localeTitle
id title challengeType videoUrl forumTopicId localeTitle
bad87fee1348bd9aedf08822 Adjust the Margin of an Element 0 https://scrimba.com/c/cVJarHW 16654 调整元素的外边距

Description

margin外边距控制元素的边框与其他元素之间的距离。 在这里,我们可以看到蓝色框和红色框都在黄色框里。请注意,红色框的margin值要比蓝色框的大,让它看起来比蓝色框要小。 当你增加蓝色的margin值,它会增加元素边框到其他周围元素的距离。

Instructions

蓝色的框margin的值要跟红色框的一样大小。

Tests

tests:
  - text: '<code>blue-box</code> class 的<code>margin</code>值应为<code>20px</code>。'
    testString: assert($(".blue-box").css("margin-top") === "20px");

Challenge Seed

<style>
  .injected-text {
    margin-bottom: -25px;
    text-align: center;
  }

  .box {
    border-style: solid;
    border-color: black;
    border-width: 5px;
    text-align: center;
  }

  .yellow-box {
    background-color: yellow;
    padding: 10px;
  }
  
  .red-box {
    background-color: crimson;
    color: #fff;
    padding: 20px;
    margin: 20px;
  }

  .blue-box {
    background-color: blue;
    color: #fff;
    padding: 20px;
    margin: 10px;
  }
</style>
<h5 class="injected-text">margin</h5>

<div class="box yellow-box">
  <h5 class="box red-box">padding</h5>
  <h5 class="box blue-box">padding</h5>
</div>

Solution

// solution required