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

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

Difference Between flex: 1 and flex: auto

Both flex: 1 and flex: auto are commonly used shorthand values for the flex property, but they behave slightly differently due to their underlying flex-grow, flex-shrink, and flex-basis values.

Comparison
  1. 1

    flex: 1 → Equivalent to flex: 1 1 0;. The item will grow to fill available space, can shrink if necessary, and starts with a base size of 0.

  2. 2

    flex: auto → Equivalent to flex: 1 1 auto;. The item will grow and shrink like flex: 1, but its base size is determined by its content (auto) instead of 0.

In short, flex: 1 treats the item as starting from zero width/height and distributes space, whereas flex: auto respects the item's intrinsic size 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. Both have flex: 1. What happens if you change one to flex: auto? Describe the visual difference.

  2. 2

    A junior developer set flex: auto on a button inside a header and now it’s way wider than expected. How would you explain why flex: 1 would fix it?

2-5 years experience
  1. 1

    Our card component has a title and a description — both flex: 1 — but on mobile, the description overflows the container. Switching to flex: auto fixes it, but breaks desktop layout. How do you solve this without media queries?

  2. 2

    A feature uses flex: auto on a dynamic list item, and sometimes the item collapses to zero height when content is empty. Why does this happen, and how would you debug it?

5-8 years experience
  1. 1

    We’re building a responsive dashboard with 3 panels that should evenly split space on desktop but stack on mobile. Some panels have dynamic content — using flex: 1 causes layout jank on load. How would you optimize this without sacrificing responsiveness?

  2. 2

    A legacy component uses flex: auto on inputs inside a form row. When we added internationalization, some labels became too long and broke the layout. Why did flex: auto make this worse than flex: 1, and how would you redesign it for scalability?

8+ years experience
  1. 1

    Our design system has a flex-based grid component used across 20+ products. Some teams use flex: 1, others use flex: auto — causing inconsistent behavior in edge cases like zero-height content or RTL layouts. How would you standardize this at the architecture level?

  2. 2

    We’re migrating from a float-based layout to flexbox. Legacy code uses flex: auto in dozens of places, and we’re seeing performance regressions on low-end devices. What’s the root cause, and how do you prioritize and phase the fix across teams?

Follow-up Questions

  • What happens if you replace flex: 1 with flex: auto on a container with dynamic text content?
  • How would you debug a layout where two flex items behave differently despite both having flex: 1?
  • Why might flex: auto cause overflow in a narrow column but flex: 1 wouldn’t?