Relatively position an element without it taking up space in document flow

后端 未结 6 1078
迷失自我
迷失自我 2020-12-04 06:02

How can I relatively position an element, and have it not take up space in the document flow?

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 06:24

    Add a margin equal to the pixels that you moved:

    Example

    .box {
        position: relative;
        top: -30px; 
        margin-bottom: -30px;
    }
    

提交回复
热议问题