-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10.定位.html
74 lines (74 loc) · 1.95 KB
/
10.定位.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
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>定位</title>
<style>
.box1{
background-color: aqua;
width: 500px;
height: 500px;
}
.box_normal{
height: 100px;
width: 100px ;
background-color: purple;
}
.box_relative{
position: relative;
background-color: blue;
width: 20px;
height: 20px;
left: 40px;
}
.box2{
background-color: yellow;
width: 400px;
height: 400px;
margin-bottom: 300px;
}
.box-absolute{
width: 100px;
height: 100px;
background-color: brown;
position: absolute;
left: 200px;
}
.box3{
background-color: aquamarine;
width: 400px;
height: 400px;
}
.box-fixed{
background-color:darkred;
width: 100px;
height: 100px;
position: fixed;
right: 0;
top: 300px;
}
</style>
</head>
<body>
<p>相对定位;绝对定位;固定定位(相对于浏览器窗口定位,页面滚动也一直显示)</p>
<h1>相对定位</h1>
<div class="box1">
<div class="box_normal"></div>
<div class="box_relative"></div>
<div class="box_normal"></div>
</div>
<h1>绝对定位</h1>
<div class="box2">
<div class="box_normal"></div>
<div class="box-absolute"></div>
<div class="box_normal"></div>
</div>
<h1>固定定位</h1>
<div class="box3">
<div class="box_normal"></div>
<div class="box-fixed"></div>
<div class="box_normal"></div>
</div>
</body>
</html>