Centering with flexbox ๐ฏ
Centering something perfectly in the middle used to be tricky. Flexbox makes it easy with three steps. We'll add them one line at a time โ tap the hint to reveal each step.
.container {
display: flex; /* step 1: turn on flexbox */
justify-content: center; /* step 2: center left-to-right */
align-items: center; /* step 3: center top-to-bottom */
}
Three short lines, each one the same property: value; shape you already know:
display: flex;turns the box into a flex container.justify-content: center;centers the children horizontally.align-items: center;centers the children vertically.
Your task
Make .container a flexbox that centers its content both ways. Drag the blocks
in order, or tap the hint to fill it in one step at a time.
โก 40 XP
Hints
index.htmliframe
Loading editorโฆ
Preview
Run your code to see test results.