相对定位

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>相对定位</title>
<style>
div{
width:100px;
height:100px;
}
.div1{
background:red;
}
.div2{
background:yellow;
position:relative;
/*position:relative;相对于原来的位置进行定位,不脱离文档流,原来的位置还在。只写这行,不定left、top、right或者bottom的话没效果*/
/*文档流就是从上到下,从左到右*/
left:200px;/*距离原来的位置200px,不是向左移动200px*/
}
.div3{
background:blue;
}
</style>
</head>
<body>
<div class="div1"></div>
<div class="div2"></div>
<div class="div3"></div>
</body>
</html>

posted on 2017-07-14 12:45  奔妈妈  阅读(81)  评论(0编辑  收藏  举报