SystemTutor
About
Sign in
Loading course documentation…
SystemTutor

COURSES

  • Data Structures & Algorithms
  • CSS MasterclassNew course
  • System DesignNew course

PRACTICE

  • Algorithm practice
  • CSS practice

LEGAL

  • Privacy Policy
  • Terms of Service
  • About

© 2026 SystemTutor. All rights reserved.

Built with 🫶 by Shatlyk

Welcome to CSS
FlexboxDirection and WrappingFlex Item SizingMain-Axis AlignmentCross-Axis AlignmentFlexbox PatternsDebugging Flexbox Sizing and aligning a flex layout
Flexbox Layouts

Debugging Flexbox

Inspect and troubleshoot flex layouts in browser tools.

When Flexbox does not behave as expected, check the container, its axes, and the available space. A valid property may have no visible effect if it is on the wrong element or has no space to work with.

Inspect the container first

In Chrome DevTools:

  1. Inspect the wrapper that should arrange the items.
  2. Confirm its applied display value is flex or inline-flex.
  3. Use the flex badge in the Elements panel to toggle the layout overlay.
  4. Inspect direction, wrapping, gaps, and the actual container dimensions.
  5. Select a direct child to inspect its item sizing and minimum sizes.

The flex editor can also change alignment visually. An overlay makes it easier to distinguish flex lines from the boxes inside them. See the Chrome Flexbox debugging guide.

Match a symptom to a question

SymptomCheck first
Items remain in normal block flow.Is the intended wrapper actually a flex container?
justify-content seems ineffective.Is there positive main-axis space after item growth and auto margins?
Vertical centering changes nothing.Which axis is vertical, and does the container have spare space?
align-content does nothing.Is wrapping enabled, and is there cross-axis space for the lines?
A long title pushes a sibling outside the container.Is an automatic minimum preventing the text item from shrinking?

Reproduce a content-size problem

.result {
  display: flex;
  width: 16rem;
  gap: 1rem;
}

.result-copy {
  flex: 1 1 0;
}

.result > button {
  flex: none;
}

The copy can grow and shrink, but its automatic minimum can still protect the width of an unbroken word. Setting a shrink factor alone does not remove that minimum.

Add these two declarations:

.result-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}
  • min-width: 0: Permits the row item to become narrower than its automatic minimum.
  • overflow-wrap: anywhere: Lets an otherwise unbreakable string break when necessary.

Try the minimum-width change on its own. The box can shrink while an unbroken identifier still sticks out of it. Then enable wrapping and watch the word break. Break opportunities created by anywhere also count when the browser calculates the item’s minimum content width.

Verify the fix

Resize the component and try longer content. Keep the button readable and ensure the title remains available. Inspect any crossed-out declaration to find the rule that overrides it, then change the stylesheet itself after confirming the experiment in DevTools.

Avoid applying overflow: hidden merely to conceal the symptom. Clipping may remove visible text without correcting the sizing decision.

Trace before changing a rule

In the result example, the copy has flex: 1 1 0 but still overflows. What should you inspect before increasing its shrink factor?

Check your reasoning

Inspect the copy item's minimum size and the unbroken text. The automatic minimum can stop the item shrinking even though its shrink factor permits it.

If you set min-width: 0 but the long word still paints outside its narrower box, what separate change helps the text fit?

Check your reasoning

Add overflow-wrap: anywhere to permit breaks within the long word. The minimum controls the box; wrapping controls the text inside it.

Key Takeaways

  • Structure: Inspect the correct container and its direct children.
  • Axes and space: Check what the alignment property is trying to distribute.
  • Minimums: A shrink factor does not override every size constraint.
  • Verification: Retest the actual content and save the confirmed stylesheet change.

Try it yourself

Try it yourself

Keep the Save button in view

HTML + CSS

Loading code editor…

Live preview

Updating…

Final output

No comparison yetChecks after 3s without edits
Loading your draft…

Take the quiz · Sizing and aligning a flex layout

How is this lesson?

Previous lessonFlexbox PatternsNext lesson Sizing and aligning a flex layout
Edit on GitHubReport on GitHub
On this page
%

On this page

Inspect the container firstMatch a symptom to a questionReproduce a content-size problemVerify the fixTrace before changing a ruleKey TakeawaysTry it yourself