一、元素默认定位:没有任何效果
position:static;
二、相对定位:以元素自身的初始位置作为参照物
position:relative;
用法:
使用left、right、top、bottom使得元素发生浮动
.box{
width: 100px;
height: 100px;
background-color: red;
position: relative;
left: 100px;
top: 100px;
}
<div class="box">box</div>
特性:
1、不会脱离文档流,但是可以飘起来(该元素仍然占据原来的位置,但是浮动到其他元素的位置时可以覆盖在其他元素上面)
2、元素占据初始位置
3、支持margin、padding auto
4、不会影响元素的类型
5、可以随意移动元素