Who can systematically summarize the differences between the three positioning modes? Thank you very much - PHP Chinese website Q&A - Who can systematically summarize the differences between the three positioning modes? Thank you very much - PHP Chinese website Q&A
Who can systematically summarize the differences between the three positioning modes? Thank you very much - PHP Chinese website Q&A - Who can systematically summarize the differences between the three positioning modes? Thank you very much - PHP Chinese website Q&A
Please watch and learn.
position定位值共有五种:
1.static,默认值。没有定位,元素出现在正常的流中(忽略 top, bottom, left, right 或者 z-index 声明)。
2.inherit,规定应该从父元素继承 position 属性的值。
3.absolute,生成绝对定位的元素,相对于 static 定位以外的第一个父元素进行定位。元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。
4.fixed,生成绝对定位的元素,相对于浏览器窗口进行定位。元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。
5.relative,生成相对定位的元素,相对于其正常位置进行定位。因此,"left:20" 会向元素的 LEFT 位置添加 20 像素。