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

What does flex-direction: row do?

Understanding flex-direction: row in CSS

flex-direction: row is the default value for a flex container. It arranges flex items horizontally along the main axis, starting from the left and going to the right (in left-to-right languages).

Key Points
  1. 1

    Items are laid out in a horizontal row along the main axis.

  2. 2

    The first item appears at the start (left) of the container, and subsequent items follow in order.

  3. 3

    Main-axis properties like justify-content control spacing between items horizontally.

  4. 4

    Cross-axis properties like align-items control vertical alignment within the container.

  5. 5

    It is suitable for creating horizontal navigation bars, rows of cards, or any layout that flows left-to-right.

Example: flex-direction: row

In this example, the flex container arranges .item elements in a horizontal row. They are evenly spaced along the main axis using justify-content and centered along the cross axis using align-items.

Best Practices
  1. 1

    Use flex-direction: row for horizontal layouts like menus, toolbars, or card rows.

  2. 2

    Combine with justify-content for horizontal spacing and align-items for vertical alignment.

  3. 3

    Test the layout on different screen sizes to ensure items remain properly aligned.

  4. 4

    Switch to row-reverse if you need to reverse the horizontal order for RTL or design purposes.

Difficulty: 3/10
Topics: flexbox layout, row vs column, responsive alignment

Scenario Questions

0-2 years experience
  1. 1

    You're building a navigation bar with five links, and they're stacking vertically instead of lining up horizontally — you've set display: flex but they're still not in a row. What’s the most likely missing or incorrect property?

  2. 2

    How would you make a card component with a title and two buttons side-by-side using flexbox, and what would happen if you accidentally set flex-direction: column instead?

  3. 3

    If you have a flex container with three items and you set flex-direction: row, but one item is much wider than the others, how does that affect the layout without any other flex properties?

2-5 years experience
  1. 1

    A mobile-first product card component works fine on desktop with flex-direction: row, but on tablet, the image and text content overlap awkwardly. How would you diagnose and fix this without breaking the desktop layout?

  2. 2

    Your team’s design system uses flex-direction: row for form fields, but in RTL locales, the labels and inputs appear in the wrong order. How would you handle this without duplicating CSS?

  3. 3

    A feature toggle caused flex-direction to switch between row and column based on user preference, but now the spacing between items is inconsistent. What could be causing this, and how would you fix it?

5-8 years experience
  1. 1

    You’re designing a reusable horizontal list component that needs to support both inline scrolling and wrapping on small screens. How would you structure the flexbox rules to handle both cases gracefully without media query bloat?

  2. 2

    A legacy component uses flex-direction: row with fixed widths, but now we need to support dynamic content length and variable screen sizes. What tradeoffs do you consider when migrating from fixed widths to flex-based sizing?

  3. 3

    In a high-performance dashboard with 50+ horizontal flex items, users report jank during resize. What CSS properties or layout strategies would you audit to improve rendering performance?

8+ years experience
  1. 1

    Your company’s design system has hundreds of components using flex-direction: row, but some are breaking in new internationalization contexts. How would you architect a scalable, maintainable solution to handle LTR/RTL without breaking existing layouts?

  2. 2

    We’re migrating from a float-based grid to flexbox across 20+ product teams. What governance, documentation, and tooling would you put in place to ensure consistent use of flex-direction: row and avoid regressions?

  3. 3

    A cross-team component library uses flex-direction: row for horizontal layouts, but the engineering team wants to switch to CSS Grid for better control. How would you evaluate the cost-benefit, manage the migration, and communicate the impact to designers and frontend teams?

Follow-up Questions

  • What happens if you set flex-direction: row on a container with very wide children?
  • How would you debug a layout where items are stacking vertically despite flex-direction: row being set?
  • When would you choose row-reverse instead of row?