Files
freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-css/adjust-the-padding-of-an-element.md
Oliver Eyton-Williams ee1e8abd87 feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

2.3 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bad88fee1348bd9aedf08825 调整元素的内边距 0 https://scrimba.com/c/cED8ZC2 301083 adjust-the-padding-of-an-element

--description--

我们暂时把要做的猫咪图片 App 放在一边,先来多了解一下如何给 HTML 添加样式。

你可能已经注意到了,所有的 HTML 元素都是以矩形为基础。

每个 HTML 元素所占有的矩形空间由这三个重要的属性来控制:内边距 padding、外边距 margin 、边框 border

padding 用来控制着元素内容与 border 之间的空隙大小。

在这个挑战中,我们可以看到蓝色框和红色框都在黄色框里面,同时,红色框比蓝色框的 padding 大。

如果你增加蓝色框的 padding 值,其中的文本内容与边框的距离就也会变大。

--instructions--

将蓝色的框的 padding 值设置成与红色框 padding 值一样。

--hints--

blue-box 这一 class 应将元素的 padding 值设置为 20px

assert($('.blue-box').css('padding-top') === '20px');

--seed--

--seed-contents--

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

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

--solutions--

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

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