* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
82 lines
1.8 KiB
Markdown
82 lines
1.8 KiB
Markdown
---
|
|
id: 587d78a3367417b2b2512acf
|
|
title: Change the Position of Overlapping Elements with the z-index Property
|
|
challengeType: 0
|
|
videoUrl: 'https://scrimba.com/c/cM94aHk'
|
|
forumTopicId: 301046
|
|
dashedName: change-the-position-of-overlapping-elements-with-the-z-index-property
|
|
---
|
|
|
|
# --description--
|
|
|
|
When elements are positioned to overlap (i.e. using `position: absolute | relative | fixed | sticky`), the element coming later in the HTML markup will, by default, appear on the top of the other elements. However, the `z-index` property can specify the order of how elements are stacked on top of one another. It must be an integer (i.e. a whole number and not a decimal), and higher values for the `z-index` property of an element move it higher in the stack than those with lower values.
|
|
|
|
# --instructions--
|
|
|
|
Add a `z-index` property to the element with the class name of `first` (the red rectangle) and set it to a value of 2 so it covers the other element (blue rectangle).
|
|
|
|
# --hints--
|
|
|
|
The element with class `first` should have a `z-index` value of 2.
|
|
|
|
```js
|
|
assert($('.first').css('z-index') == '2');
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```html
|
|
<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>
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```html
|
|
<style>
|
|
div {
|
|
width: 60%;
|
|
height: 200px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.first {
|
|
background-color: red;
|
|
position: absolute;
|
|
z-index: 2;
|
|
}
|
|
.second {
|
|
background-color: blue;
|
|
position: absolute;
|
|
left: 40px;
|
|
top: 50px;
|
|
z-index: 1;
|
|
}
|
|
</style>
|
|
<div class="first"></div>
|
|
<div class="second"></div>
|
|
```
|