---
id: 587d78a3367417b2b2512acf
title: Change the Position of Overlapping Elements with the z-index Property
challengeType: 0
videoUrl: ''
localeTitle: 使用z-index属性更改重叠元素的位置
---
## Description
当元素定位为重叠时,默认情况下,HTML标记中稍后出现的元素将显示在其他元素的顶部。但是, z-index
属性可以指定元素彼此堆叠的顺序。它必须是整数(即整数而不是小数),并且元素的z-index
属性的较高值会使其在堆栈中的移动值高于具有较低值的值。
## Instructions
将z-index
属性添加到类名为first
(红色矩形)的元素中,并将其设置为值2,以便覆盖另一个元素(蓝色矩形)。
## Tests
```yml
tests:
- text: 具有类first
的元素的z-index
值应为2。
testString: 'assert($(".first").css("z-index") == "2", "The element with class first
should have a z-index
value of 2.");'
```
## Challenge Seed
## Solution
```js
// solution required
```