How to remove an element from the flow?

前端 未结 9 1734
Happy的楠姐
Happy的楠姐 2020-12-24 00:11

I know position: absolute will pop an element from the flow and it stops interacting with its neighbors.

What other ways are there to achieve this?

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-24 00:36

    I know this question is several years old, but what I think you're trying to do is get it so where a large element, like an image doesn't interfere with the height of a div?

    I just ran into something similar, where I wanted an image to overflow a div, but I wanted it to be at the end of a string of text, so I didn't know where it would end up being.

    A solution I figured out was to put the margin-bottom: -element's height, so if the image is 20px hight,

    margin-bottom: -20px; vertical-align: top;

    for example.

    That way it floated over the outside of the div, and stayed next to the last word in the string.

提交回复
热议问题