Skip to the page

CSS · Build it

Flexbox (center a div, and more)

The interviewer asks

Center a div horizontally and vertically, three ways. Then explain flex: 1, and why my flex item won't shrink below its content.

Then

Follow-ups the interviewer asks next

  1. flex: 1 = 1 1 0%; flex-basis vs width.
  2. min-width: auto on flex items, and fixing overflow with min-width: 0.
  3. gap vs margins.
  4. align-items vs align-content vs justify-content.

The answer

What a strong answer covers

  • Flex (justify-content and align-items: center), grid (place-items: center), absolute plus transform
  • Main vs cross axis; wrapping

The red pen

Common traps

Avoid:not knowing the min-width: 0 overflow fix.

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview