Free Tool

Flexbox Playground

Struggling to understand Flexbox? Trust me, we've all been there. This interactive tool will help you visualize how justify-content, align-items, and align-content work together (I'm still struggling with the latter!).

1. Container Properties
2. Sizing & Spacing
3. Interactive Preview
4. Output Code

Flexbox Layout FAQ

What is the difference between Justify Content and Align Items?

These two properties dictate how items are distributed along your container's axes. justify-content controls the alignment along the main axis. If your flex direction is a row, this controls the horizontal spacing. align-items controls the cross axis. If your flex direction is a row, this dictates how items align vertically within the container. When building a PWA, mastering both is essential for adapting to varying screen sizes.

What does Align Content do and why isn't it working?

This is the most common Flexbox trap! align-content controls the spacing between multiple lines of flex items. However, it does absolutely nothing if your items are all on a single line. It only takes effect when you have flex-wrap: wrap; enabled and your items have actually wrapped onto multiple lines. It is incredibly useful for spacing out a grid of product cards in your PWA.

When should I use Flexbox vs CSS Grid?

The general rule of thumb is that Flexbox is built for one-dimensional layouts, and CSS Grid is built for two-dimensional layouts. If you just need a row of buttons, a navigation bar, or a stack of cards that wrap neatly to the next line, Flexbox is perfect. If you need explicit control over columns and rows simultaneously, like a complex PWA dashboard organized in a bento layout, you should switch to CSS Grid.

Why aren't my flex items wrapping?

By default, Flexbox tries to fit all of your items onto a single line. It will squish and shrink your elements as much as possible before it lets them overflow. To fix this, you must apply flex-wrap: wrap; to the parent container. You can toggle this setting in the playground above and resize the preview box to see it in action.

How do I center a div perfectly?

The absolute easiest way to center an element both horizontally and vertically is to apply three lines of CSS to its parent container: display: flex;, justify-content: center;, and align-items: center;. In Tailwind, you can achieve this exact result by adding flex justify-center items-center to the parent div.

Your app here

Got Flexbox figured out?

Now add Progressier to your web app to distribute it without the hassles of the app stores.

Generate PWA See plans