2018-10-10 22:03:03 +00:00
|
|
|
|
---
|
|
|
|
|
id: bad87fee1348bd9aedf08822
|
2020-12-16 07:37:30 +00:00
|
|
|
|
title: 调整元素的外边距
|
2018-10-10 22:03:03 +00:00
|
|
|
|
challengeType: 0
|
2019-12-13 05:47:57 +00:00
|
|
|
|
videoUrl: 'https://scrimba.com/c/cVJarHW'
|
|
|
|
|
forumTopicId: 16654
|
2018-10-10 22:03:03 +00:00
|
|
|
|
---
|
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
# --description--
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
`margin(外边距)`控制元素的边框与其他元素之间的距离。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
在这里,我们可以看到蓝色框和红色框都在黄色框里。请注意,红色框的`margin`值要比蓝色框的大,让它看起来比蓝色框要小。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
当你增加蓝色的`margin`值,它会增加元素边框到其他周围元素的距离。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
# --instructions--
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
蓝色的框`margin`的值要跟红色框的一样大小。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
# --hints--
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
`blue-box` class 的`margin`值应为`20px`。
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
```js
|
|
|
|
|
assert($('.blue-box').css('margin-top') === '20px');
|
2018-10-10 22:03:03 +00:00
|
|
|
|
```
|
|
|
|
|
|
2020-12-16 07:37:30 +00:00
|
|
|
|
# --solutions--
|
2020-08-13 15:24:35 +00:00
|
|
|
|
|