-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path4.fixed_pos.html
More file actions
40 lines (38 loc) · 887 Bytes
/
4.fixed_pos.html
File metadata and controls
40 lines (38 loc) · 887 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>Fixed Positioning</title>
<style>
/* Fixed positioning can be used to keep something on a certain area of the screen even while scrolling. It is easier to understand this one by seeing it in action so take a look at the example below in a browser. */
#red_box {
position: absolute;
top: 0;
left: 50%;
width: 200px;
height: 200px;
background: #ee3e64;
}
#blue_box {
position: fixed; /* fixed 200px from the top and 50% from the left. */
top: 200px;
left: 50%;
width: 200px;
height: 200px;
background: #44accf;
}
#green_box {
position: absolute;
top: 5000px;
left: 50%;
width: 200px;
height: 200px;
background: #b7d84b;
}
</style>
</head>
<body>
<div id="red_box">Absolute</div>
<div id="blue_box">Fixed</div>
<div id="green_box">Absolute</div>
</body>
</html>