Questions
38 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?
38 / 51

How do flex items align when the container has align-items: stretch?

Flex Items Alignment with align-items: stretch

When a flex container has align-items: stretch, all flex items are stretched to fill the container along the cross axis by default. This makes items expand to match the height (for row direction) or width (for column direction) of the container, unless a fixed size or min/max constraints are applied.

Key Points
  1. 1

    Default behavior: Flex items stretch to fill the container along the cross axis.

  2. 2

    Overridden by fixed sizes: If a flex item has a specific height (row) or width (column), the fixed size takes precedence over stretching.

  3. 3

    Respecting min/max: min-height, max-height, min-width, and max-width limit the stretching of flex items.

  4. 4

    Works for all items unless align-self is used on individual items to override the container's align-items.

Example: align-items: stretch

In this example, Item 1 and Item 3 stretch to fill the 200px container height, while Item 2 maintains its fixed height of 100px.

Difficulty: 3/10
Topics: flexbox alignment, default behavior, container constraints

Scenario Questions

0-2 years experience
  1. 1

    You have a flex container with three divs inside, all with different text lengths, but they’re not the same height — what’s the most likely reason, and how do you fix it?

  2. 2

    If I set align-items: stretch on a flex container and none of the children have explicit height, what happens to their heights?

  3. 3

    I added a padding to one flex item and now it’s taller than the others — why isn’t stretch making them equal?

2-5 years experience
  1. 1

    Our card grid uses flexbox with align-items: stretch, but on mobile, one card’s image is cutting off content — what’s probably going wrong, and how do you debug it?

  2. 2

    A designer says the buttons in our nav bar aren’t aligned properly — they’re all stretch-height, but one is taller. What three things would you check in DevTools?

  3. 3

    We have a responsive sidebar with flex items that stretch vertically, but on tablets, the content overflows. How do you fix this without breaking desktop layout?

5-8 years experience
  1. 1

    We’re building a dynamic dashboard with variable-height widgets in a flex container — stretch works fine, but performance degrades on low-end devices. What’s the hidden cost of stretch, and how would you optimize it?

  2. 2

    In our component library, align-items: stretch causes unintended height inflation in nested flex containers. How do you design a reusable layout system that avoids this while keeping flexibility?

  3. 3

    A legacy app uses stretch for vertical alignment, but now we’re migrating to CSS Grid. What edge cases in stretch behavior should we audit before deprecating it?

8+ years experience
  1. 1

    We’re standardizing our design system across 12 product teams, and stretch is inconsistently used — some teams rely on it for vertical alignment, others avoid it due to layout instability. How do you drive alignment without forcing a rigid solution?

  2. 2

    Our CSS architecture has hundreds of flex containers using stretch; now we’re introducing a new accessibility requirement that caps max-height. How do you migrate safely without breaking existing layouts or requiring manual updates across teams?

  3. 3

    Stretch behavior interacts unpredictably with viewport units and scroll containers in our mobile web app. As the lead architect, how do you decide whether to deprecate stretch entirely or invest in a custom layout abstraction layer?

Follow-up Questions

  • What if one item has a fixed height — does it still stretch?
  • How would you make one item not stretch while others do?
  • Have you ever seen this cause layout bugs in responsive designs?