定位position

position(定位模式和位偏移)

  1. 定位模式:静态定位(static默认)、相对定位(relative)、绝对定位(absolute)、固定定位(fixed)
  2. 位偏移(left、right、top、bottom)

特性:

  1. 脱离文档流
  2. 提高层级(z-index)
  3. 相对定位会保留位置(占位),绝对定位不保留位置(不占位)子绝父相
  4. 绝对定位和固定定位默认转换为行内块元素特性

加了定位的盒子  margin:0 auto 没有效果

position:relative;
left:0;
top:0;
z-index:999;

猜你喜欢

转载自blog.csdn.net/weixin_42661283/article/details/86667162
今日推荐