Make #wrap the positioning context.
Acceptance criteria
- 1.Make #wrap the positioning context.
CSS Tutorial · CSS Layout
These 10 tasks go with the Anchor Positioning chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “Position tooltips, menus, and callouts relative to an anchor while providing fallback placements for constrained space. The chapter covers anchor association, relative insets, position areas, sizing, fallbacks, and progressive enhancement.” .
1.Create the anchor contextexercise · easy · 10 min
Make #wrap the positioning context.
Passes when: Make #wrap the positioning context.
2.Pin to the bottom-rightexercise · easy · 10 min · practice plan
Place #box at the bottom right of its context.
Passes when: Place #box at the bottom right of its context.
3.Offset from an edgeexercise · easy · 10 min · practice plan
Place #box 16px from the top and 24px from the left.
Passes when: Place #box 16px from the top and 24px from the left.
4.Stretch across the contextexercise · easy · 10 min · practice plan
Use inset 0 so #box fills its positioned parent.
Passes when: Use inset 0 so #box fills its positioned parent.
5.Raise the anchored elementexercise · medium · 10 min · practice plan
Pin it and lift it above siblings with z-index.
Passes when: Pin it and lift it above siblings with z-index.
6.Fix the missing contextbug fix · easy · 8 min
Without a positioned parent the box anchors to the page.
Passes when: Without a positioned parent the box anchors to the page.
7.Fix the wrong edgesbug fix · easy · 8 min · practice plan
The box should sit bottom-right, not top-left.
Passes when: The box should sit bottom-right, not top-left.
8.Fix the z-index without positionbug fix · easy · 8 min · practice plan
z-index is ignored on a static element.
Passes when: z-index is ignored on a static element.
9.Fix inset written as a single edgebug fix · easy · 8 min · practice plan
inset sets all four edges at once.
Passes when: inset sets all four edges at once.
10.Fix the swapped offsetsbug fix · easy · 8 min · practice plan
The top and left values are the wrong way round.
Passes when: The top and left values are the wrong way round.
Between them these tasks cover Positioning relative to another element, inset and Fallback techniques.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.