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

How can you make items stack vertically on mobile and horizontally on desktop using Flexbox?

Responsive Flexbox Layout

Use Flexbox with media queries to stack items vertically on small screens and horizontally on larger screens.

Key Techniques
  1. 1

    Set display: flex on the container.

  2. 2

    Use flex-direction: column for mobile layouts.

  3. 3

    Change flex-direction to row inside a media query for desktop.

  4. 4

    Use gap to control spacing between items.

Example: Responsive Flexbox
Difficulty: 4/10
Topics: responsive layout, flexbox, media queries

Scenario Questions

0-2 years experience
  1. 1

    We have a simple navigation bar with three links. How would you write the CSS so that on screens narrower than 600px the links stack vertically, but on wider screens they appear side‑by‑side using Flexbox?

  2. 2

    If you set flex-direction: column on a container and then add a media query for larger screens, which property would you change to make the items lay out horizontally?

  3. 3

    What CSS would you add to ensure the items wrap correctly when the viewport changes from mobile to desktop?

2-5 years experience
  1. 1

    Our product page uses a Flexbox container for feature cards. On mobile they stack correctly, but on desktop they still appear stacked. Walk me through how you'd debug this and what changes you'd make.

  2. 2

    We need to support both portrait and landscape tablets, stacking vertically in portrait and horizontally in landscape. How would you implement this with Flexbox and media queries, and what trade‑offs would you consider?

  3. 3

    Explain why adding width: 100% to the flex items broke the horizontal layout on desktop, and how you'd fix it.

5-8 years experience
  1. 1

    Our site has a global Flexbox grid component used across dozens of pages. We now need it to switch between column and row layouts based on breakpoint, but also support legacy browsers that lack flex-direction. How would you design this component to be maintainable and performant?

  2. 2

    Discuss the impact of using flex-basis versus fixed width in the responsive Flexbox layout for large data tables, especially regarding reflow and paint performance on mobile devices.

  3. 3

    We want to add a CSS custom property to control the breakpoint for switching layout direction across the whole design system. How would you implement this and ensure consistency without causing specificity wars?

8+ years experience
  1. 1

    Our company is migrating a monolithic CSS codebase to a design system built with CSS‑in‑JS. The new system must allow components to automatically switch between vertical and horizontal orientation based on device type. How would you architect the solution to minimize duplication and support future breakpoints?

  2. 2

    Several teams have built their own responsive Flexbox utilities, leading to inconsistent breakpoints and naming. As a staff engineer, how would you lead a refactor to unify these utilities, and what governance process would you put in place?

  3. 3

    Consider a scenario where we need to support server‑side rendering of critical CSS for above‑the‑fold content, including the responsive Flexbox layout. How would you ensure the correct layout is applied on first paint for both mobile and desktop users without a flash of unstyled content?

Follow-up Questions

  • What would happen if you omitted the media query entirely?
  • How does `flex-wrap` affect the layout when items overflow the container?
  • Are there any accessibility or performance considerations with this approach?