-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10-CSS Positioning & Z-Index.html
More file actions
94 lines (82 loc) · 1.87 KB
/
10-CSS Positioning & Z-Index.html
File metadata and controls
94 lines (82 loc) · 1.87 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>10 - CSS Positioning & Z-Index</title>
<style>
/* Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Common Box */
.box {
width: 150px;
height: 150px;
background: lightblue;
margin: 10px;
}
/* Relative Example */
.box1 {
position: relative;
top: 30px;
left: 30px;
background: orange;
}
/* Absolute Example */
.parent {
width: 300px;
height: 200px;
background: lightgreen;
margin: 20px;
position: relative;
}
.child {
width: 100px;
height: 100px;
background: red;
position: absolute;
top: 20px;
left: 20px;
}
/* Fixed Example */
.fixed-btn {
position: fixed;
right: 20px;
bottom: 20px;
background: black;
color: white;
padding: 10px 20px;
cursor: pointer;
}
/* Sticky Example */
.header {
position: sticky;
top: 0;
background: purple;
color: white;
padding: 10px;
}
</style>
</head>
<body>
<!-- Relative Example -->
<div class="box box1">Box 1</div>
<div class="box box2">Box 2</div>
<!-- Absolute Example -->
<div class="parent">
<div class="child">I am absolute</div>
</div>
<!-- Sticky Example -->
<div class="header">I am Sticky Header</div>
<!-- Fixed Example -->
<button class="fixed-btn">Chat</button>
<!-- Scroll Content -->
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
<!-- Repeat to create long scroll -->
</p>
</body>
</html>