-
Notifications
You must be signed in to change notification settings - Fork 9
/
Position absolute, relative, fixed and sticky in CSS.html
53 lines (45 loc) · 1.42 KB
/
Position absolute, relative, fixed and sticky in CSS.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
51
52
53
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Positons in CSS</title>
<style>
/* relative: Positions the element relative to its normal positon and will leave a gap at its normal position*/
/* position: relative; */
/* absolute: Positions the element relative to the positon of its first parent*/
/* position: absolute; */
/* top: 34px;
left: 134px; */
/* fixed: Positions the element relative to the browser window; */
/* position: fixed;
right: 4px;
bottom: 2px */
/* sticky: Positions the element relative to the users scroll position */
.container{
border:2px solid black;
background-color: aqua;
height:3444px;
}
.box{
border:2px solid black;
background-color: antiquewhite;
display: inline-block;
width: 334px;
height: 200px;
}
#box3{
position:fixed;
}
</style>
</head>
<body>
<div class="container">
<div class="box" id="box1">1</div>
<div class="box" id="box2">2</div>
<div class="box" id="box3">3</div>
<div class="box" id="box4">4</div>
</div>
</body>
</html>