1.4 KiB
1.4 KiB
id | challengeType | videoUrl | forumTopicId | title |
---|---|---|---|---|
587d78a3367417b2b2512acf | 0 | https://scrimba.com/c/cM94aHk | 301046 | 使用 z-index 属性更改重叠元素的位置 |
Description
z-index
属性指定元素的堆叠次序。z-index
的取值是整数,数值大的元素优先于数值小的元素显示。
Instructions
first
的元素(红色的方块)添加 z-index
属性并赋值为 2,使它显示在蓝色方块的上方。
Tests
tests:
- text: 'class 为 <code>first</code> 的元素的 <code>z-index</code> 值应该为 2。'
testString: assert($('.first').css('z-index') == '2');
Challenge Seed
<style>
div {
width: 60%;
height: 200px;
margin-top: 20px;
}
.first {
background-color: red;
position: absolute;
}
.second {
background-color: blue;
position: absolute;
left: 40px;
top: 50px;
z-index: 1;
}
</style>
<div class="first"></div>
<div class="second"></div>
Solution
// solution required