1.3 KiB
1.3 KiB
id | challengeType | videoUrl | forumTopicId | localeTitle |
---|---|---|---|---|
587d78a3367417b2b2512ad0 | 0 | https://scrimba.com/c/cyLJqU4 | 301043 | 使用 margin 属性将元素水平居中 |
Description
margin
值设置为 auto
。
同样的,这个方法也对图片奏效。图片默认是内联元素,但是可以通过设置其 display
属性为 block
来把它变成块级元素。
Instructions
div
添加值为 auto
的 margin
属性将其居中显示。
Tests
tests:
- text: '<code>div</code> 的 <code>margin</code> 应该为 <code>auto</code>。'
testString: assert(code.match(/margin:\s*?auto;/g));
Challenge Seed
<style>
div {
background-color: blue;
height: 100px;
width: 100px;
}
</style>
<div></div>
Solution
// solution required