对于position的取值,常见的有:static、relative、absolute 和 fixed,还有较少被关注到的:initial,inherit和unset。
1.initial
可用于设置 CSS 属性为它的默认值,可作用于任何 CSS 样式(IE不支持该关键字)
2.inherit
可继承属性,从父元素那获取对应属性的经过计算与转换的值,如果父元素没有,则向上查找,直到使用浏览器默认值为止
可继承属性:
border-collapse
border-spacing
caption-side
color
cursor
direction
empty-cells
font
font-family
font-stretch
font-size
font-size-adjust
font-style
font-variant
font-weight
letter-spacing
line-height
list-style
opacity
list-style-image
list-style-type
quotes
text-align
text-indent
text-transform
white-space
word-spacing
不可继承属性:
background
border
bottom
clear
display
float
height
left
margin
outline
overflow
padding
position
right
top
visibility
width
z-index
3.unset
顾名思义,不设置,一个CSS属性设置了unset值,如果这个属性是默认继承属性,该值等同于inherit,非继承,则等同于initial