Files
freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/change-the-position-of-overlapping-elements-with-the-z-index-property.md

27 lines
747 B
Markdown
Raw Normal View History

---
id: 587d78a3367417b2b2512acf
title: 使用 z-index 属性更改重叠元素的位置
challengeType: 0
videoUrl: 'https://scrimba.com/c/cM94aHk'
forumTopicId: 301046
---
# --description--
当一些元素重叠时,在 HTML 里后出现的元素会默认显示在更早出现的元素的上面。你可以使用 `z-index` 属性指定元素的堆叠次序。`z-index` 的取值是整数,数值大的元素优先于数值小的元素显示。
# --instructions--
给 class 为 `first` 的元素(红色的方块)添加 `z-index` 属性并赋值为 2使它显示在蓝色方块的上方。
# --hints--
class 为 `first` 的元素的 `z-index` 值应该为 2。
```js
assert($('.first').css('z-index') == '2');
```
# --solutions--