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

What is the use of the flex-wrap property?

Understanding the flex-wrap Property in Flexbox

The flex-wrap property in CSS defines whether flex items should stay on a single line or wrap onto multiple lines when they overflow the flex container. It allows for more flexible and responsive layouts by controlling how items flow within a flex container.

Available Values of flex-wrap
  1. 1

    nowrap (default): All flex items are placed on a single line, and they may overflow the container.

  2. 2

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

  3. 3

    wrap-reverse: Flex items wrap onto multiple lines but in reverse order (from bottom to top).

Example: Using flex-wrap in a Flex Container

In this example, when the width of the flex container is too small to fit all items in one line, flex-wrap: wrap causes the extra items to move to the next line instead of overflowing.

Best Practices
  1. 1

    Use flex-wrap: wrap for responsive designs where items should move to new lines on smaller screens.

  2. 2

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

  3. 3

    Avoid using nowrap when items have fixed widths that can cause overflow issues.

Difficulty: 3/10
Topics: flex-wrap behavior, responsive layout, overflow handling

Scenario Questions

0-2 years experience
  1. 1

    You're building a product grid on a mobile page, and the items are squeezing into a single row instead of wrapping. How would you fix it using flex-wrap?

  2. 2

    If I set flex-wrap: wrap on a container but the items still don't wrap on a tablet, what’s the first thing you’d check?

  3. 3

    What happens if you forget to set flex-wrap and the container has a fixed width with too many items?

2-5 years experience
  1. 1

    Our product card component works fine on desktop, but on mobile, the text overflows and breaks the layout. How would you use flex-wrap to fix this without hardcoding heights?

  2. 2

    A teammate says flex-wrap: wrap is causing inconsistent spacing between rows — how would you investigate and resolve this?

  3. 3

    We have a dynamic list of tags that should wrap, but sometimes they overflow on smaller screens. What’s your approach to make this robust?

5-8 years experience
  1. 1

    You're designing a responsive navigation bar that switches from horizontal to vertical on mobile — how do you use flex-wrap to avoid layout jank during resize, and what edge cases do you watch for?

  2. 2

    In a component library, flex-wrap is used inconsistently across components. How would you standardize its usage to ensure predictable behavior across devices and content lengths?

  3. 3

    A high-traffic page has a dynamic tag cloud that wraps poorly on low-end devices. How would you optimize the flex-wrap implementation for performance and rendering stability?

8+ years experience
  1. 1

    We’re migrating a legacy UI from floats to flexbox, and flex-wrap is causing cascading layout breaks in 30+ components. How would you approach this migration without breaking production?

  2. 2

    How would you design a cross-team CSS architecture guideline for flex-wrap usage that balances flexibility, accessibility, and performance across 50+ micro-frontends?

  3. 3

    A global product uses flex-wrap in a multilingual UI where text length varies by 300% between languages. How do you ensure layout integrity and avoid content clipping at scale?

Follow-up Questions

  • What happens if you set flex-wrap: nowrap on a container with very wide items?
  • How would you debug a layout where items are wrapping when they shouldn't?
  • Why might flex-wrap: wrap-reverse cause unexpected visual behavior?