FlexFrog Blog
Home · Essays on CSS flexbox, layout, and the browser box model.
- subgrid is not flex —
Subgrid lets a child grid inherit parent tracks. Flex has no equivalent — that absence is why teams switch layouts to grid.
- column-reverse and the scroll-anchor —
A chat that sticks to the latest message used to need JS. flex-direction: column-reverse with overflow: auto does it in CSS.
- safe and unsafe alignment —
When a flex item is bigger than its container, alignment can scroll content away. Safe and unsafe keywords pick the trade-off.
- aspect-ratio meets flex —
CSS aspect-ratio with flex removes the padding-bottom media-card hack and ResizeObserver workarounds for clean cards.
- the min-width: auto trap —
Flex items have a hidden min-width of auto set to content size. Long words and oversized images blow the layout out.
- auto margins in flex are a feature —
margin: auto on a flex item absorbs free space along that side — the classic push-one-button-to-the-end layout trick.
- flex-basis vs width: which one wins —
Set both flex-basis and width on a flex item and one silently loses. The rule is simple, but most tutorials explain it wrong.
- align-content: the property tutorials skip —
align-content does nothing on a single-line flex container. Wrap, and it becomes the only way to control the cross axis.
- flex-wrap and the mythical flex line —
flex-wrap turns one flex line into many. Spec flex lines behave less like rows and more like stacked mini-containers.
- order considered harmful —
The flex order property reorders boxes visually but leaves the DOM untouched — a WCAG 1.3.2 failure for keyboard users.
- gap is the flex property you forget —
CSS gap landed in flexbox in 2021. It replaces margin hacks, negative margins, and :not(:last-child) with one declaration.
- min-content, max-content, fit-content —
Flex items overflow when content cannot shrink below its intrinsic minimum. Sizing keywords let you name that minimum.
- justify vs align: which axis —
justify-content runs on the main axis; align-items on the cross axis. Flip flex-direction and everything swaps.
- flex-grow, shrink, and basis —
The flex shorthand is three properties in a trench coat. Understand each one before writing flex: 1 and hoping.
- When to reach for Grid instead —
Flexbox is for one-dimensional layout. CSS Grid is for two. Use the tool that matches the shape of what you are laying out.