CSS中display,position,float对布局、box的影响
有3个属性和布局以及box的创建有关:'display', 'position' 和 'float':
一般情况下,'display'属性值=其指定的值。
指定值/特定值 | 计算值 |
inline-table | table |
inline, run in, table-row-group, table-column, table-column-group, table-header-group, table-footer-group, table-row, table-cell, table-caption, inline-block |
block |
others | same as specified |
1.如果'display'值为'none',则'position' 和 'float'无作用。不生成box。
2.否则,如果'position'值为'absolute' 或 'fixed', box被绝对定位,'float'不起作用,而'display'的值按上表的指定值设定。
3.否则,如果'float'的值不是'none', box是浮动的,'display'的值按上表的指定值设定。
4.否则,如果元素为根元素,'display'的值按上表的指定值设定。
(翻译自:CSS basic box model)