.card { position: relative; } .badge { position: absolute; top: 12px; right: 12px; }The badge is positioned relative to the card, not the whole page.
LESSON 50 OF 100
Anchor a badge in the card’s top-right corner.
The relatively positioned card establishes the reference block. The absolute badge leaves normal flow, while top and right set its distance from the card edges.
.card { position: relative; } .badge { position: absolute; top: 12px; right: 12px; }The badge is positioned relative to the card, not the whole page.
.card { position: static; } .badge { position: absolute; top: 12px; right: 12px; }Without a positioned ancestor, the badge can use another reference block and visually leave the card.
Complete the card and badge positioning, then set top and right to 12px.
The relative-parent to absolute-child relationship keeps coordinates inside the component.
ANALYSIS REQUEST
The initial discussion is without obligation. You receive an honest recommendation, suitable stages and the factors that affect price.