Predict which reference box positions a label and whether its original space stays occupied.
A label can overlap the corner of a card while the paragraph below it stays in ordinary flow. To predict where each box lands, first ask whether positioning keeps its usual space. Then identify the box from which its offsets are measured.
With the initial position, static, a box stays in normal flow. position: relative lays it out there first, then allows an offset from that spot. Move a label down ten pixels this way and the next line stays where it was. The label can paint over it.
With position: absolute, the label leaves normal flow. Its siblings lay themselves out as though it occupied no space. To anchor the label to a card, give the card relative positioning. The card can stay in its original spot while its padding box becomes the label’s containing block, the reference for the label’s offsets. Offsets of zero at the top and right bring the label against the inside of the card’s border on those sides.
A fixed box also leaves normal flow. Its usual reference is the viewport, so it stays in view as the document scrolls. Some ancestor styles, including a transform, can establish a different reference.
A sticky heading keeps its place in flow. A top inset of zero lets it follow the top edge of its nearest scrollport as it would otherwise scroll out, until it reaches the boundary of its containing block. When positioned boxes overlap, their painting order is a separate decision.
Try it yourself
HTML + CSS