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

How can you make flex items wrap onto multiple lines?

Understanding the flex-wrap Property in Flexbox

The flex-wrap property in CSS determines whether flex items should stay on a single line or wrap onto multiple lines when they exceed the container’s available space. It allows for more responsive and adaptive layouts by controlling how items flow within a flex container.

Available Values of flex-wrap
  1. 1

    nowrap (default): All flex items are kept on a single line, even if they overflow the container.

  2. 2

    wrap: Flex items wrap onto multiple lines from top to bottom (in a horizontal layout).

  3. 3

    wrap-reverse: Flex items wrap onto multiple lines from bottom to top (in a horizontal layout).

Example: Using flex-wrap in a Flex Container

In this example, when the total width of the flex items exceeds the container width, flex-wrap: wrap causes the extra items to move to the next line instead of overflowing.

Best Practices
  1. 1

    Use flex-wrap: wrap to make layouts responsive and avoid overflow issues.

  2. 2

    Combine flex-wrap with align-content to control spacing between multiple flex lines.

  3. 3

    Avoid nowrap when working with fixed-width items in smaller viewports to prevent content clipping.

Difficulty: 3/10
Topics: flex-wrap, line-breaking, responsive layout

Scenario Questions

0-2 years experience
  1. 1

    You're building a product grid with 4 items per row on desktop, but on mobile they stack vertically. How would you make them wrap onto multiple lines when the screen gets narrower?

  2. 2

    I set flex-wrap: wrap on my container, but the items are still all on one line. What’s the most likely thing I forgot to check?

  3. 3

    If I have a flex container with 10 items and I want them to wrap into 2 rows of 5 on tablet, what CSS properties do I need to set?

2-5 years experience
  1. 1

    Our card grid looks fine on desktop, but on some tablets the last row has only one item and it looks awkward. How would you fix the wrapping behavior without hardcoding breakpoints?

  2. 2

    A teammate added flex-wrap: wrap to our header navigation, but now the menu items jump around on resize. What could be causing this, and how would you debug it?

  3. 3

    We’re using flex-wrap in a dynamic list where items have varying heights. Users report inconsistent vertical spacing between rows. What’s likely happening, and how would you stabilize it?

5-8 years experience
  1. 1

    We have a responsive component that wraps flex items, but on low-end devices it causes layout thrashing during resize. How would you optimize the wrapping behavior for performance?

  2. 2

    In our design system, we need flex-wrap to behave consistently across 12 different components with varying content lengths. How would you architect a reusable utility that prevents visual jank and maintains alignment?

  3. 3

    A legacy component uses flex-wrap with dynamic content from a CMS. Sometimes items wrap unpredictably due to font loading or dynamic translations. How would you make this robust without breaking existing layouts?

8+ years experience
  1. 1

    We’re migrating from a float-based grid to flexbox across 50+ legacy pages. How would you approach the rollout to avoid visual regressions in wrapped layouts, especially with third-party widgets that assume fixed widths?

  2. 2

    Our design system supports 8 global breakpoints and 3 different content density modes. How would you architect the flex-wrap strategy to scale across these dimensions without creating a maintenance nightmare?

  3. 3

    A cross-team component library uses flex-wrap, but different teams override container widths inconsistently. How would you enforce predictable wrapping behavior at an architectural level without restricting flexibility?

Follow-up Questions

  • What happens if you set flex-wrap: wrap but the container has no explicit width?
  • How does flex-wrap interact with min-width on flex items?
  • Why might items still not wrap even when flex-wrap is set to wrap?