Lesson 3 of 8
Positioning
- 14 min
- 5 checks
- 3 hints
- Go to task
Goal
One element on top of another
Explanation
position: absolute takes an element out of the normal flow of the page and positions it relative to its nearest positioned ancestor, meaning the closest element containing it whose position isn't static.
The whole trick is to put position: relative on the parent so it becomes the reference point, then put absolute on the child. Forget relative on the parent and the child ends up in the corner of the page.
Use inset-block-start and inset-inline-start instead of top and left. The logical properties follow the direction of the page and flip with it, while top and left stay the same whatever the direction.
Your task
Place .badge at the top of .card on its start edge, and make it appear above everything around it.
Checks
5 checks- The card becomes the reference point with relative
- The badge leaves the normal flow with absolute
- The badge is at the top of the card, not the middle
- The badge is on the start edge
- The badge has a z-index so it doesn't hide under other elements