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

How can you make one flex item take up the remaining space in a container?

Making a Flex Item Fill Remaining Space

In Flexbox, you can make a single flex item occupy the remaining space in a container by using the flex-grow property or the shorthand flex property.

Key Techniques
  1. 1

    Set the container's display to flex.

  2. 2

    Set the flex item you want to expand with flex: 1 (or flex-grow: 1) so it takes up remaining space.

  3. 3

    Other flex items can have flex: 0 or fixed widths so they do not grow.

  4. 4

    Combine with gap for spacing between items if needed.

Example: One Flex Item Fills Remaining Space

In this example, the middle .item-flex expands to fill all remaining space between the two fixed-width items, demonstrating how flex: 1 allows a flex item to take up available space.

Difficulty: 3/10
Topics: flex-grow, flex-basis, remaining space allocation

Scenario Questions

0-2 years experience
  1. 1

    You have a header with a logo on the left and a search bar on the right — you want the search bar to stretch and fill all the remaining space. How would you do that with flexbox?

  2. 2

    I see a flex container with three items: two have fixed widths, and the third is supposed to take up the rest. The third item isn't expanding — what’s the most likely mistake?

  3. 3

    How would you make a button fill the remaining horizontal space in a nav bar without using absolute positioning?

2-5 years experience
  1. 1

    A card component has a title, a description, and a CTA button — the description should expand to fill space, but on mobile it overflows. What’s going wrong, and how would you fix it?

  2. 2

    We added flex-grow: 1 to a sidebar panel, but now it’s pushing content off-screen on small screens. How would you debug and resolve this without breaking desktop layout?

  3. 3

    A modal has a scrollable content area that should fill the remaining height after header and footer — it works in Chrome but not Safari. What could be the issue, and how would you investigate?

5-8 years experience
  1. 1

    You’re designing a responsive dashboard with collapsible sidebars and dynamic panels — how do you ensure the main content area reliably fills remaining space across breakpoints, devices, and zoom levels without layout thrashing?

  2. 2

    In a legacy app, flex-grow is used inconsistently across components — sometimes it works, sometimes it doesn’t. What systemic issues might cause this, and how would you refactor for reliability?

  3. 3

    A team built a layout using flex-grow on multiple elements, but performance degrades on low-end devices when resizing. What’s the root cause, and how would you optimize the rendering pipeline?

8+ years experience
  1. 1

    We’re migrating from a grid-based layout system to flexbox for our design system — how do you ensure consistent remaining-space behavior across 50+ components without introducing regressions in legacy pages?

  2. 2

    A cross-team component library uses flex-grow differently in various contexts, causing inconsistent UI behavior. How would you enforce standardization at the architecture level, and what tradeoffs would you consider between flexibility and predictability?

  3. 3

    Our app supports 12 languages with RTL/LTR switching — flex-grow-based layouts break in RTL mode on some browsers. How would you design a future-proof, maintainable solution that scales across internationalization requirements?

Follow-up Questions

  • What happens if you set width: 100% on the flex item instead of flex-grow?
  • How would you debug if the item isn't expanding even with flex-grow: 1?
  • What if there are two items both with flex-grow: 1 — how is space divided?