Questions
7 of 51
1What is Flexbox in CSS?
2What problem does Flexbox solve compared to traditional layouts like float or inline-block?
3How do you create a flex container?
4What are the main and cross axes in Flexbox?
5What does the display: flex property do?
6What is the difference between display: flex and display: inline-flex?
7What are flex items?
8How do you change the direction of items in a flex container?
9What does flex-direction: row do?
10What does flex-direction: column do?
11What is the purpose of the justify-content property?
12What does the align-items property control?
13What are the possible values of align-content?
14What is the difference between align-items and align-content?
15What is the use of the flex-wrap property?
16How can you make flex items wrap onto multiple lines?
17What does the flex-flow shorthand property do?
18How does the order property affect flex items?
19How does the align-self property work?
20How do you vertically center content using Flexbox?
21What does the flex shorthand property represent?
22What are the three components of the flex shorthand property?
23What is the default value of the flex property?
24How do flex-grow, flex-shrink, and flex-basis work individually?
25What is the difference between flex: 1 and flex: auto?
26What is the difference between flex: 1 and flex: auto?
27What is the purpose of the gap property in Flexbox?
28How does Flexbox handle overflowing content?
29What’s the difference between justify-content: space-around and space-between?
30How does Flexbox handle fixed and flexible widths together?
31Can Flexbox be nested?
32How is Flexbox different from CSS Grid?
33When would you use Flexbox instead of Grid?
34Can you use Flexbox and Grid together in the same layout?
35How does Flexbox differ from traditional float-based layouts?
36Does Flexbox affect the box model or positioning of elements?
37How does Flexbox handle min-width and max-width constraints?
38How do flex items align when the container has align-items: stretch?
39What is the difference between flex: 0 1 auto and flex: 1 0 auto?
40How does flex-basis differ from width?
41How do you prevent a flex item from shrinking?
42How would you create a horizontal navigation bar using Flexbox?
43How do you center a div both horizontally and vertically using Flexbox?
44How can you make a responsive layout using Flexbox?
45How can you make one flex item take up the remaining space in a container?
46How do you create equal-height columns using Flexbox?
47How can you align the last flex item to the right side of the container?
48How can you reorder items visually using Flexbox without changing the HTML structure?
49How can you make items stack vertically on mobile and horizontally on desktop using Flexbox?
50How do you prevent an element from wrapping in a flex container?
51How can you align items to the bottom of a container using Flexbox?
07 / 51

What are flex items?

Understanding Flex Items in CSS

Flex items are the direct child elements of a flex container. Once an element is inside a container with display: flex or display: inline-flex, it automatically becomes a flex item and can be aligned, ordered, and sized using Flexbox properties.

Key Points About Flex Items
  1. 1

    Only the direct children of a flex container become flex items; nested elements are not affected unless their parent is also a flex container.

  2. 2

    Flex items can grow, shrink, and be distributed along the main and cross axes using properties like flex-grow, flex-shrink, flex-basis, align-self, and order.

  3. 3

    They respect the container's flex direction (row, column, etc.) and wrapping rules (flex-wrap).

  4. 4

    Flex items can have a combination of fixed and flexible sizing for responsive layouts.

Example: Flex Items in a Container

In this example, the three .item elements are flex items inside the .container flex container. They are evenly spaced along the main axis and grow equally because of flex: 1.

Best Practices
  1. 1

    Use flex items for content that needs flexible alignment or sizing within a container.

  2. 2

    Combine flex-grow, flex-shrink, and flex-basis for responsive layouts.

  3. 3

    Use align-self to override cross-axis alignment for individual items when needed.

  4. 4

    Avoid nesting too many flex containers unnecessarily to keep layouts manageable and performant.

Difficulty: 3/10
Topics: flexbox layout, flex-item behavior, main-axis vs cross-axis

Scenario Questions

0-2 years experience
  1. 1

    You're building a card layout with three buttons side by side, but one button is wider than the others and they're not aligning properly — how would you fix it using flexbox?

  2. 2

    If you set display: flex on a container but the children aren't lining up horizontally, what’s the most likely cause and how would you check it?

  3. 3

    A button inside a flex container is overflowing its parent — what flex properties would you adjust to make it fit without breaking the layout?

2-5 years experience
  1. 1

    A navigation bar with dynamic links breaks on mobile — some items wrap unexpectedly even though you set flex-wrap: nowrap. What could be causing this, and how would you debug it?

  2. 2

    You built a responsive dashboard with three panels using flexbox, but on tablet, the middle panel collapses to zero width. What’s likely wrong with the flex properties, and how would you fix it without hardcoding widths?

  3. 3

    A team member says their flex item is ignoring max-width — what common flexbox misunderstanding might they have, and how would you explain the interaction between flex-basis and max-width?

5-8 years experience
  1. 1

    You’re designing a dynamic form builder where users can add/remove fields — how would you ensure the layout remains stable and accessible when flex items are added/removed dynamically, and what edge cases would you anticipate?

  2. 2

    A legacy component uses flexbox for a complex grid, but it’s causing layout thrashing on low-end devices. How would you optimize the flex item rendering performance without switching to CSS Grid?

  3. 3

    You inherit a UI library where flex items behave inconsistently across browsers — what are the top 3 vendor-specific flexbox quirks you’d investigate, and how would you standardize behavior?

8+ years experience
  1. 1

    You’re leading a migration from float-based layouts to flexbox across 50+ legacy components — what’s your strategy to minimize regressions, and how would you measure success?

  2. 2

    A cross-team component library uses flexbox for alignment, but different teams interpret flex-grow differently, causing inconsistent UIs. How would you enforce a consistent flex item behavior policy across teams?

  3. 3

    Your app supports 10+ languages with RTL and LTR layouts — how would you design a flexbox-based layout system that handles dynamic text expansion and direction changes without breaking, and what long-term maintenance tradeoffs would you consider?

Follow-up Questions

  • What happens if you set flex-grow: 1 on one item but not the others?
  • How does flex-basis interact with width when both are set?
  • Why might an item not shrink even when flex-shrink is set to 1?