Does setting position to relative on a div takes it out of document flow? [closed]

≡放荡痞女 提交于 2019-12-12 02:52:27

问题


Does just declaring position:relative on a div without specify position coordinates such as top,left etc takes it out of normal document ? Plz provide reasoning.

thanks dkj.


回答1:


No it doesn't. relative positioning doesn't affect the layout, the positioned element is still in its initial place logically, hence the occupied space is reserved.

But it could be displaced visually by top, right, bottom, left offsets/properties.

9.3.1 Choosing a positioning scheme: 'position' property

relative The box's position is calculated according to the normal flow (this is called the position in normal flow). Then the box is offset relative to its normal position. When a box B is relatively positioned, the position of the following box is calculated as though B were not offset. [...]




回答2:


No:

Elements that are positioned relatively are still considered to be in the normal flow of elements in the document.

via https://developer.mozilla.org/en-US/docs/Web/CSS/position#Absolute_positioning



来源:https://stackoverflow.com/questions/26560303/does-setting-position-to-relative-on-a-div-takes-it-out-of-document-flow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!