是<span>
带有 position: absolute;
的元素无需将其更改为 display: block;
即可拥有高度、宽度、填充等或 inline-block;
?
它似乎可以工作,但是所有浏览器都可以省略 display: block/inline-block
吗?对于 <span>
带有 position: absolute;
的元素?
最佳答案
规范 says yes :
Otherwise, if 'position' has the value 'absolute' or 'fixed', the box is absolutely positioned, the computed value of 'float' is 'none', and display is set according to the table below. The position of the box will be determined by the 'top', 'right', 'bottom' and 'left' properties and the box's containing block.
该表表示任何内联显示
值(inline, table-row-group, table-column, table-column-group, table-header-group, table-footer-group, table -row, table-cell, table-caption, inline-block) 成为 block
。
关于css - 具有 "position: absolute;"的 <span> 元素是否表现为 block 级元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17737194/