-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tut20.html
50 lines (48 loc) · 1.36 KB
/
Tut20.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Visibility and Z-index</title>
<style>
* {
color: white;
}
.box{
width: 120px;
border: 2px solid black;
height: 120px;
}
#box1{
z-index: 3; /* z-index will not work here because position is not set here */
background-color: blueviolet
}
#box2{
/* display none hides element and its empty space */
/* display: none; */
/* it hides element but show empty space */
/* visibility: hidden; */
position: absolute;
top: 100px;
/* Z-index will work only for position :relative sticky ,absolute, fixed */
z-index: 2;
background-color: rgb(248, 172, 9)
}
#box3{
position: relative;
top: 12px;
z-index: 1;
background-color: rgb(253, 6, 18)
}
#box4{
background-color: rgb(102, 94, 11)
}
</style>
</head>
<body>
<div class="box" id="box1">box1</div>
<div class="box" id="box2">box2</div>
<div class="box" id="box3">box3</div>
<div class="box" id="box4">box4</div>
</body>
</html>