* 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>
116 lines
2.0 KiB
Markdown
116 lines
2.0 KiB
Markdown
---
|
||
id: bad87fee1348bd9aedf08823
|
||
title: 给元素添加负外边距
|
||
challengeType: 0
|
||
videoUrl: 'https://scrimba.com/c/cnpyGs3'
|
||
forumTopicId: 16166
|
||
dashedName: add-a-negative-margin-to-an-element
|
||
---
|
||
|
||
# --description--
|
||
|
||
元素的 `margin(外边距)` 用来控制元素 `border(边框)` 与其周围元素之间的距离大小。
|
||
|
||
如果你把元素的 `margin` 设置为负值,元素会变得占用更多空间。
|
||
|
||
# --instructions--
|
||
|
||
请将蓝色框的 `margin` 设为负值,跟红色框 `margin` 的属性值设置成一样的大小。
|
||
|
||
将蓝色框的 `margin` 设置为 `-15px`,它会让蓝色框填满整个黄色框。
|
||
|
||
# --hints--
|
||
|
||
class 为 `blue-box` 的元素的 `margin` 应设置为 `-15px`。
|
||
|
||
```js
|
||
assert($('.blue-box').css('margin-top') === '-15px');
|
||
```
|
||
|
||
# --seed--
|
||
|
||
## --seed-contents--
|
||
|
||
```html
|
||
<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: -15px;
|
||
}
|
||
|
||
.blue-box {
|
||
background-color: blue;
|
||
color: #fff;
|
||
padding: 20px;
|
||
margin: 20px;
|
||
}
|
||
</style>
|
||
|
||
<div class="box yellow-box">
|
||
<h5 class="box red-box">padding</h5>
|
||
<h5 class="box blue-box">padding</h5>
|
||
</div>
|
||
```
|
||
|
||
# --solutions--
|
||
|
||
```html
|
||
<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: -15px;
|
||
}
|
||
|
||
.blue-box {
|
||
background-color: blue;
|
||
color: #fff;
|
||
padding: 20px;
|
||
margin: 20px;
|
||
margin-top: -15px;
|
||
}
|
||
</style>
|
||
|
||
<div class="box yellow-box">
|
||
<h5 class="box red-box">padding</h5>
|
||
<h5 class="box blue-box">padding</h5>
|
||
</div>
|
||
```
|