A friendly tool to learn flex box by moving boxes around.
Give it a try!
A small collection of typical flexbox use cases.
To center an element in both direction use display: flex
, justify-content: center
and align-items: center
on the parent element. You don't need to put any styles on the child element.
To create a centered column put display: flex
, flex-direction: column
, justify-content: center
and align-items: center
on the parent element. You don't need to put any styles on child elements.
Put display: flex
and align-items: stretch
on your flex container. If children do not fill the full height, try resetting their height
and max-height
.
Turn the container into flex-container with display: flex
, then push child to the bottom by setting align-items: flex-end
and to the left with justify-content: flex-start
on the flex-container. Child element need no flex properties.
justify-content
or align-items
to get what you want. You choose one of possible positions and get the answer to the question: how to make it with flexbox?flex-direction
all the margins get automatically updated to keep spacing in main and and cross axis the way they were.canvas
element, no weird javascript magic calculating pixels. This is built with flexbox. If you feel like opening this builder in developer tools, you can. However, CSS box will no longer reflect your layout.