freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-css/use-clockwise-notation-to-s...

2.9 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
bad87fee1348bd9afdf08726 Use Clockwise Notation to Specify the Margin of an Element 0 使用顺时针符号指定元素的边距

Description

让我们再试一次,但这次有margin 。不是单独指定元素的margin-top margin-right margin-bottommargin-left属性,而是可以在一行中指定它们,如下所示: margin: 10px 20px 10px 20px;这四个值的工作方式类似于时钟toprightbottomleft并且将产生与使用边特定边距指令完全相同的结果。

Instructions

使用Clockwise Notationblue-box的元素在其顶部和左侧提供40px的边距,但在其底部和右侧仅为20px

Tests

tests:
  - text: 你的<code>blue-box</code>类应该给元素顶部<code>40px</code>的<code>margin</code> 。
    testString: 'assert($(".blue-box").css("margin-top") === "40px", "Your <code>blue-box</code> class should give the top of elements <code>40px</code> of <code>margin</code>.");'
  - text: 您的<code>blue-box</code>类应该赋予元素<code>20px</code> <code>margin</code>的权利。
    testString: 'assert($(".blue-box").css("margin-right") === "20px", "Your <code>blue-box</code> class should give the right of elements <code>20px</code> of <code>margin</code>.");'
  - text: 你的<code>blue-box</code>类应该给元素的底部提供<code>20px</code>的<code>margin</code> 。
    testString: 'assert($(".blue-box").css("margin-bottom") === "20px", "Your <code>blue-box</code> class should give the bottom of elements <code>20px</code> of <code>margin</code>.");'
  - text: 你的<code>blue-box</code>类应该给元素左边<code>40px</code>的<code>margin</code> 。
    testString: 'assert($(".blue-box").css("margin-left") === "40px", "Your <code>blue-box</code> class should give the left of elements <code>40px</code> of <code>margin</code>.");'

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: 20px 40px 20px 40px;
  }

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

  .blue-box {
    background-color: blue;
    color: #fff;
  }
</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