position的值有:
relative absolute fixed static inherit
- fixed 固定定位,相对于浏览器窗口进行定位
举例:
.container{
width: 300px;
height:300px;
border: 1px solid #890;
}
.container>.myFixed{
position:fixed;
width:50px;
height:50px;
background:#ccc;
bottom:30px;
}
<div class="container">
<div class="myFixed"></div>
</div>
absolute 绝对定位, 相对于值不为 static的第一个父元素进行定位。
relative 相对定位, 相对于其正常位置进行定位。
static 默认值。没有定位,元素出现在正常的流中。
inherit 规定从父元素继承 position 属性的值。