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?
position: fixed;
will also "pop" an element out of the flow, as you say. :)
position: absolute
must be accompanied by a position. e.g. top: 1rem; left: 1rem
position: fixed
however, will place the element where it would normally appear according to the document flow, but prevent it from moving after that. It also effectively set's the height to 0px (with regards to the dom) so that the next element shifts up over it.
This can be pretty cool, because you can set position: fixed; z-index: 1
(or whatever z-index you need) so that it "pops" over the next element.
This is especially useful for fixed position headers that stay at the top when you scroll, for example.