Skip to content

Flexbox Not Working

Quick summary

Your flex-direction, justify-content, or align-items properties are not working because the container is missing display: flex.

Why this happens

  • Missing 'display: flex' on the container element

  • Typo in the display value (e.g., 'display: flexbox' instead of 'display: flex')

  • The CSS rule is not matching the target element

Minimal example

✗ Broken code
.container {
  flex-direction: row;
  justify-content: center;
}
✓ Fixed code
.container {
  display: flex;
  flex-direction: row;
  justify-content: center;
}

Without display: flex, the container is a normal block element and flex properties have no effect. Adding display: flex activates the flexbox layout.

How to diagnose

  • Inspect the element in DevTools and check if display: flex is in the computed styles

  • Verify the CSS selector matches the container element

  • Check for typos in the display property value

How to fix

  • Add 'display: flex' to the container element

  • Use 'display: inline-flex' if the container should be inline

  • Fix any typos in the property name or value

How to prevent

  • Always start flexbox CSS with display: flex

  • Use DevTools to verify computed styles are applied

Related Resources

Related Glossary

Related Lessons

Related Practice

← Back to language