-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlec25.html
64 lines (59 loc) · 1.78 KB
/
lec25.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
61
62
63
64
<!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>Positions in Css</title>
<style>
.container{
border: 2px solid blue;
background-color: palevioletred;
margin-top: 10px;
margin-right: 10px;
height: 4000px;
}
.box{
border: 2px solid orangered;
width: 200px;
height: 120px;
margin: 4px;
display: inline-block;
background-color: purple;
}
#box3{
position: relative; /*This is relative positioning which moves the element from its previous position*/
top: 30px;
}
#box4{
position:absolute;
top:30px;
/* Absolute positioning mmoves the element from the position of its first parent */
}
#box5{
position: absolute;
top: 200px;
}
#box2{
position: fixed;
/*Fixed positioning mmoves the element from the position of the browser window and keeps its position fixed een when scrolling*/
bottom: 8px;
right: 8px;
}
#box1{
position: sticky;
top: 200px;
/*Same as absolute positoning*/
}
</style>
</head>
<body>
<div class="container">
<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>
<div class="box" id="box5">Box5</div>
</div>
</body>
</html>