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

What is the difference between align-items and align-content?

Difference Between align-items and align-content in Flexbox

Both align-items and align-content are Flexbox properties used to align items along the cross axis, but they serve different purposes depending on the number of flex lines in the container.

Key Differences
  1. 1

    align-items aligns individual items within a single flex line along the cross axis.

  2. 2

    align-content aligns multiple lines of flex items (when wrapping occurs) within the flex container.

  3. 3

    align-items works regardless of whether items wrap or not.

  4. 4

    align-content only applies when there is extra space in the cross axis and when flex-wrap is enabled.

  5. 5

    align-items controls how each item is aligned within its line, while align-content controls how the lines themselves are spaced inside the container.

Example: align-items vs align-content

In this example, align-items: center vertically centers each item within its line, while align-content: space-between distributes the multiple lines evenly across the container height.

Best Practices
  1. 1

    Use align-items for aligning items within a single row or column.

  2. 2

    Use align-content when dealing with multiple flex lines (using flex-wrap).

  3. 3

    Combine both for fine-tuned control over layout alignment along the cross axis.

  4. 4

    If your layout has only one line of items, align-content has no visible effect.

Difficulty: 6/10
Topics: flexbox layout, multi-line alignment, container overflow behavior

Scenario Questions

0-2 years experience
  1. 1

    You're building a card grid with 3 items per row, and they're all sticking to the top — how would you center them vertically within each row?

  2. 2

    If you set align-items: center on a flex container with 5 items in one line, but the container is taller than the items, where do the items appear?

  3. 3

    What happens if you apply align-content: space-between to a flex container that only has one line of items?

2-5 years experience
  1. 1

    A responsive product grid breaks on mobile — items are stacking but the vertical spacing looks uneven. You've set align-items: center, but the content still looks misaligned. What’s likely wrong?

  2. 2

    Your team’s component library has a flex-based sidebar that sometimes has 1 item, sometimes 5. When it has multiple items, the vertical spacing between them feels off. How would you fix it without breaking the single-item case?

  3. 3

    A designer complains that a modal’s content is aligned to the top on tablets but centered on desktop. You’ve used align-items: center — what could be causing this inconsistency?

5-8 years experience
  1. 1

    You're designing a dynamic dashboard with collapsible panels that can wrap into multiple rows. How do you ensure consistent vertical spacing between rows when the container height changes dynamically, and why can't you just use align-items?

  2. 2

    A legacy component uses flexbox with flex-wrap: wrap and align-content: stretch, but now it's causing overflow on low-res screens. How would you refactor this to be more robust without breaking existing layouts?

  3. 3

    In a high-performance UI library, you notice that align-content is causing layout thrashing on mobile devices during resize. How would you optimize this without losing visual consistency?

8+ years experience
  1. 1

    You're leading a cross-team effort to unify layout systems across 12 product surfaces. Some teams use align-content for spacing, others use margins — how do you standardize this without introducing regressions or performance issues?

  2. 2

    Your company is migrating from a legacy grid system to CSS Flexbox. Teams are misusing align-content as a spacing tool because they don’t understand its line-based behavior. How do you architect a training and linting strategy to prevent this at scale?

  3. 3

    A design system component that uses align-content works fine in the demo but breaks in production when content is dynamically loaded. How do you design the API to make this behavior predictable and safe for engineers across teams?

Follow-up Questions

  • What happens if you set align-content but don't have multiple lines?
  • How would you debug a layout where items are misaligned even though align-items looks correct?
  • Can align-content work on a flex container with flex-wrap: nowrap?