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

How does Flexbox handle overflowing content?

Handling Overflow in Flexbox

Flexbox provides flexible ways to handle overflowing content within a container. Overflow can occur when the combined size of flex items exceeds the container's size.

Key Points
  1. 1

    By default, flex items shrink to fit within the container according to their flex-shrink values.

  2. 2

    You can use the overflow property on the container (overflow: auto, overflow: hidden, overflow: scroll) to control scrolling or clipping of excess content.

  3. 3

    Setting flex-wrap: wrap allows items to wrap onto multiple lines instead of overflowing.

  4. 4

    Flex items can also grow using flex-grow to fill available space, but this only affects remaining space, not overflow.

Example: Handling Overflow

In this example, items that exceed the container width wrap to the next line due to flex-wrap: wrap, and the overflow: auto ensures scrollbars appear if needed.

Difficulty: 6/10
Topics: flex-wrap, overflow-behavior, flex-shrink

Scenario Questions

0-2 years experience
  1. 1

    You have a flex container with three items, but one item's text is too long and it's pushing others out of view. What’s the quickest fix to make everything fit without changing the HTML?

  2. 2

    If I set flex-wrap: nowrap on a row and the content overflows, what happens to the items? How do you make them wrap instead?

  3. 3

    A button in a flex row is overflowing its container. You can’t change the text. What CSS property do you adjust to make it shrink?

2-5 years experience
  1. 1

    Our product card component uses flexbox to align title, price, and button — but on small screens, the title gets cut off instead of wrapping. How would you debug and fix this without breaking the desktop layout?

  2. 2

    A modal’s content area uses flexbox and overflows vertically on iOS Safari, but works fine elsewhere. What’s likely causing this, and how would you investigate?

  3. 3

    We added a dynamic badge to a flex header and now the logo gets squished. The badge has min-width: 40px. How do you allow the logo to shrink gracefully without clipping?

5-8 years experience
  1. 1

    You’re designing a responsive dashboard with 8+ dynamic panels in a flex container. Users can resize panels, and content inside can be arbitrarily long. How do you prevent overflow from breaking layout while preserving usability and accessibility?

  2. 2

    A legacy component uses flexbox with flex-shrink: 0 on text containers to avoid truncation, but now it’s causing horizontal scroll on tablets. How would you refactor this without breaking existing tests or design expectations?

  3. 3

    In a high-traffic e-commerce product grid, flex items with variable-length titles are causing layout thrashing on low-end devices. How would you optimize for performance while handling overflow gracefully?

8+ years experience
  1. 1

    We’re migrating from a float-based grid to flexbox across 50+ legacy components. Many have overflow issues due to hardcoded widths and min-widths. How do you prioritize fixes, enforce consistency, and prevent regressions at scale?

  2. 2

    Our design system uses flexbox for all layout primitives, but we’re seeing inconsistent overflow behavior across platforms (web, native wrappers, PWAs). How do you architect a unified, maintainable solution that accounts for platform-specific quirks?

  3. 3

    A cross-team component library has inconsistent overflow handling in flex containers — some teams use overflow: hidden, others use text-overflow: ellipsis, and some just let it break. How do you establish a company-wide standard that balances UX, accessibility, and technical debt?

Follow-up Questions

  • What if the content is dynamic and you can't predict its size?
  • How would you debug this if it only breaks on mobile?
  • Why might flex-shrink: 0 cause issues in a responsive header?