CSS 日常练习----定位的基准

记录日常 CSS 练习的小知识点 —— 定位的基准

定位的基准

点击预览

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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>我是test</title>
<style>
div{
width: 100px;
height: 100px;
border: 50px solid brown;
border-bottom-color: red;
}
.p{
position: relative;
/* margin: 100px; */
padding: 50px;
}
.c{
position: absolute;
top:100px;
left: 100px;
}
</style>
</head>
<body>
<p>定位的基准是内边距的左上角</p>
<div class="p">
<div class="c"></div>
</div>
</body>
</html>
0%