The snippet library.
Small, practical examples. Search by task or narrow things down below.
Align flex items at the main-axis end
CSS: Flex-end uses the trailing edge of the flex container for packing.
CSS✓ Tested
Allow a long flex child to shrink inside its container
CSS: Min-width zero removes the default content-size floor so local overflow handling can take effect.
CSS✓ Tested
Change visual order without changing DOM order
CSS: Order changes flex painting positions while keyboard and reading order still follow the document.
CSS✓ Tested
Give an item the remaining horizontal space
CSS: A growing flex item absorbs free space after fixed items have been sized.
CSS✓ Tested
Override cross-axis alignment for one item
CSS: Align-self changes one item without changing its siblings’ alignment.
CSS✓ Tested
Prevent an item from shrinking
CSS: Flex-shrink zero preserves a required size even when the container overflows.
CSS✓ Tested
Push flex items to opposite ends
CSS: Space-between distributes free main-axis space between items.
CSS✓ Tested
Push one flex item away from its siblings
CSS: An auto inline-start margin consumes remaining main-axis space.
CSS✓ Tested
Specify a flex item’s initial main size
CSS: Flex-basis establishes the starting main-axis size before growth or shrinkage.
CSS✓ Tested
Stack flex items vertically
CSS: Flex-direction column makes the main axis vertical.
CSS✓ Tested