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

What is the difference between flex: 1 and flex: auto?

Difference Between flex: 1 and flex: auto

The flex shorthand property allows you to control the growth, shrinkage, and base size of flex items. flex: 1 and flex: auto are common shorthand values but differ in how they treat the base size of items.

Key Differences
  1. 1

    flex: 1 → Equivalent to flex: 1 1 0;. The item grows to fill available space, can shrink if needed, and starts from a base size of 0.

  2. 2

    flex: auto → Equivalent to flex: 1 1 auto;. The item grows and shrinks like flex: 1, but its base size is its content's intrinsic size (auto).

Essentially, flex: 1 ignores the content size initially, distributing all extra space equally, whereas flex: auto respects the intrinsic size of the item before distributing remaining space.

Example: flex: 1 vs flex: auto
Difficulty: 6/10
Topics: flex-grow, flex-basis, flex-shrink

Scenario Questions

0-2 years experience
  1. 1

    You have two side-by-side divs inside a flex container — one has a short label, the other has a long paragraph. If you set both to flex: 1, how will they size? What if you change one to flex: auto?

  2. 2

    A junior dev set flex: auto on a button inside a flex row, and now it’s way wider than expected. How would you explain why that happened?

  3. 3

    If you have a flex container with three items and only one has flex: 1 while the others have no flex, what happens when the container shrinks?

2-5 years experience
  1. 1

    We have a header with a logo, title, and button — the title should take up remaining space, but when the screen is narrow, the button wraps. We tried flex: 1 on the title, but it didn’t help. What’s likely wrong, and how would you fix it?

  2. 2

    A card component uses flex: auto on its description text, but on mobile, the text overflows the container. Why does this happen, and what’s a better approach?

  3. 3

    Our dashboard has two panels side-by-side. One uses flex: 1, the other flex: auto. On some devices, the auto one becomes too narrow. How would you investigate and resolve this inconsistency?

5-8 years experience
  1. 1

    We’re building a responsive form layout where inputs need to expand intelligently. Some fields have placeholder text, others have long default values. When should we use flex: 1 vs. flex: auto, and what edge cases break each approach?

  2. 2

    A legacy component uses flex: auto on dynamic content, causing layout thrashing on low-end devices. How would you optimize this without breaking existing layouts?

  3. 3

    In a complex grid of cards, we noticed inconsistent sizing between flex: 1 and flex: auto elements when nested inside scrollable containers. What underlying CSS layout mechanics are at play, and how would you design a robust solution?

8+ years experience
  1. 1

    We’re migrating a legacy UI framework that uses flex: auto everywhere for dynamic content. The team wants to standardize on flex: 1 for performance and predictability. What are the architectural risks, and how would you plan a phased rollout without breaking 50+ components?

  2. 2

    Our design system has two flex-based layout primitives: one for ‘expandable content’ and one for ‘content-aware sizing’. How would you define their contracts, and when would you choose one over the other at the system level?

  3. 3

    A cross-team component library uses flex: auto in shared base styles, but product teams report inconsistent behavior across browsers. How would you architect a solution that enforces predictable behavior at scale, and what metrics would you track to validate success?

Follow-up Questions

  • What happens if you have two children with flex: 1 and one has a lot of text?
  • Why might flex: auto cause unexpected overflow in a scrollable container?
  • How would you debug a layout where flex: 1 isn’t behaving like you expected?