position

作者: MuYs | 来源:发表于2021-05-06 10:20 被阅读0次

absolute:绝对定位,相对与第一个属性不是static的父元素进行定位

fixed:固定定位,相对于浏览器窗口进行定位

relative: 相对定位,相对于其它元素正常定位

static:不定位

inherit:继承父元素的position

sticky:基于滚动情况的定位,若内容处于显示窗口则为relative效果,若内容被滚动则为fixed效果,类似固钉效果(IE不支持,chrome 56+

initial:默认值(static效果)

unset: 相当于inherit

unset关键字是inherit和initial的结合,若设置该值的属性为可继承属性则为inherit,不可继承则为initial(IE不支持

.parent {
  color: blue;
  border: 1px solid red;
}
.child {
  color: unset;
  border: unset;
}
//color是可继承属性,border是不可继承属性,所以child属性相当于
.child {
  color: inherit;  //即color: blue;
  border: initial;  //即border: none;
}

相关文章

网友评论

      本文标题:position

      本文链接:https://www.haomeiwen.com/subject/hdardltx.html