Do elements with “position: absolute;” behave as block-level elements?

前端 未结 2 514
深忆病人
深忆病人 2020-12-07 03:44

Are elements with position: absolute; able to have a height, width, padding, etc. without changing it to display: block;

2条回答
  •  心在旅途
    2020-12-07 04:18

    The spec 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.

    The table says that any inline display values (inline, table-row-group, table-column, table-column-group, table-header-group, table-footer-group, table-row, table-cell, table-caption, inline-block) become block.

提交回复
热议问题