-
Notifications
You must be signed in to change notification settings - Fork 0
/
tut25-Position.html
60 lines (59 loc) · 1.56 KB
/
tut25-Position.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
54
55
56
57
58
59
60
<!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>Positioning in CSS</title>
<style>
*{
box-sizing: border-box;
}
.con{
background-color: burlywood;
height: 2000px;
}
.box{
border:4px double rgb(30, 145, 30);
width: 90px;
height: 90px;
display: inline-block;
}
#box1{
position: static;
}
#box2{
position:absolute;
left: 30px;
top: 30px;
/* we can change position from the parent position */
}
#box3{
position: relative;
left: 20px;
top: 20px;
/* we can change position from its relative old position */
}
#box4{
position: fixed;
top: 100px;
/*It will stick to the screen while scrolling untill the container height*/
}
#box5{
margin:50px;
position: sticky;
top: 100px;
/*It will stick to the screen while scrolling */
}
</style>
</head>
<body>
<div class="con">
<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 class="box" id="box5">5</div>
</div>
</body>
</html>