一、position的四个属性值
- static:默认值
- relative:相对定位
- absolute:绝对定位
- fixed:绝对定位
二、示例
1、初始状态
- HTML部分:
<div class="div1"> <div class="div11">div11</div> </div> <div class="div2">div2</div> <div class="div3">div3</div>
- CSS部分:
.div1{ height: 100px; width: 500px; background-color: blueviolet; } .div11{ height: 50px; width: 200px; background-color:blue; } .div2{ height: 100px; width: 500px; background-color:bisque; } .div3{ height: 100px; width: 500px; background-color:aquamarine; }
- 初始效果: