定位
2018-09-12 本文已影响0人
neko233
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.box1{
background-color: red;
width: 200px;
height: 200px;
}
.box2{
background-color: yellow;
width: 200px;
height: 200px;
/*相对定位,相对于原来位置定位*/
/*position: relative;*/
/*绝对定位 脱离文档轴 原点为最近的开启定位的祖先元素原点*/
/*position: absolute;*/
/*固定定位 脱离文档轴 根据浏览器窗口定位*/
position: absolute;
left: 200px;
top: 200px;
}
.box3{
background-color: green;
width: 200px;
height: 200px;
}
.s1{
width: 200px;
height: 200px;
background-color: yellow;
}
</style>
</head>
<body>
<!-- div.box$*3 -->
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<span class="s1">span</span>
</body>
</html>