Skip to content
Preptima

CSS & Layout interview questions

The cascade and specificity, flexbox and grid, stacking contexts, and responsive strategy.

4 questions in Frontend Engineering.

medium4

mediumConcept

How do you decide between flexbox and grid, and why does z-index so often not do what you expect?

Flexbox distributes items along one axis and lets content decide the sizes; grid defines tracks up front and places items into them, aligning in both axes. z-index looks broken because it only orders siblings inside one stacking context, and ordinary properties like transform and opacity create new ones. It also connects css grid to the point an interviewer is testing.

5 minentry, mid, senior
mediumConcept

A fixed header starts scrolling away with the page after someone adds an animation to a wrapper div. What happened, and how would you track it down?

A transform, filter, perspective or containment on an ancestor makes that ancestor the containing block for fixed-position descendants, so the header is now positioned and clipped relative to the wrapper instead of the viewport. Use this CSS answer to show the decision, trade-off, and evidence rather than a memorised definition. It also connects positioning to the point an interviewer is testing.

4 minmid, senior