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

What does the align-items property control?

Understanding align-items in Flexbox

The align-items property in Flexbox controls the alignment of flex items along the cross axis of a flex container. While justify-content manages spacing along the main axis, align-items ensures proper vertical or horizontal alignment depending on the flex direction.

Key Points
  1. 1

    align-items aligns all flex items along the cross axis (perpendicular to the main axis).

  2. 2

    Common values include:

    • flex-start: items are aligned at the start of the cross axis.
    • flex-end: items are aligned at the end of the cross axis.
    • center: items are centered along the cross axis.
    • stretch (default): items stretch to fill the container along the cross axis.
    • baseline: items align along their text baseline.
  3. 3

    align-items affects all items in the container, while align-self can override it for individual items.

  4. 4

    Useful for controlling vertical alignment in a row or horizontal alignment in a column layout.

Example: Using align-items

In this example, align-items: center vertically centers all .item elements along the cross axis, while justify-content: space-around spaces them evenly along the main axis.

Best Practices
  1. 1

    Choose align-items values based on desired cross-axis alignment.

  2. 2

    Combine with justify-content for full control over both axes.

  3. 3

    Use align-self for individual items when they need different alignment from the rest.

  4. 4

    Test layouts in both row and column directions to ensure proper alignment.

Difficulty: 3/10
Topics: flexbox layout, cross-axis alignment, container vs item behavior

Scenario Questions

0-2 years experience
  1. 1

    You're building a navigation bar with five links, and they're not vertically centered even though you set align-items: center. What’s the most likely cause, and how would you fix it?

  2. 2

    Your team’s design shows a card with an image and text stacked vertically, but the text is sticking to the top. You’ve set display: flex on the card — what align-items value should you use to center the text horizontally?

  3. 3

    If you set align-items: flex-end on a row-direction flex container, where will the items align? Show me with a quick sketch or describe it.

2-5 years experience
  1. 1

    A responsive product grid breaks on mobile: items are misaligned when the container switches from row to column. You’ve set align-items: stretch everywhere — why might this still look wrong on small screens, and how would you debug it?

  2. 2

    Your modal dialog has a form with labels and inputs. On desktop, align-items: center looks fine, but on mobile, the inputs stretch too wide and look awkward. What’s happening, and how would you adjust the layout without breaking desktop?

  3. 3

    A teammate says ‘align-items doesn’t work on my flex container’ — you check the code and see it’s applied correctly. What are three possible reasons this might appear broken, and how would you investigate?

5-8 years experience
  1. 1

    You’re designing a reusable card component that must support both row and column layouts depending on screen size. How do you ensure align-items behaves predictably across both modes without requiring consumers to override it?

  2. 2

    In a high-traffic dashboard, we have hundreds of flex-based cards with dynamic content. We’re seeing layout thrashing on scroll. Could align-items be contributing? What performance considerations should you evaluate when using it at scale?

  3. 3

    Your design system uses align-items: baseline for text-heavy components, but it causes inconsistent vertical alignment when icons or buttons are mixed in. How would you redesign this to maintain visual harmony without introducing brittle overrides?

8+ years experience
  1. 1

    We’re migrating from a float-based layout system to flexbox across 50+ legacy components. Many rely on hardcoded heights and margins for alignment. How would you approach standardizing align-items usage without breaking existing UIs or requiring a full rewrite?

  2. 2

    Your team owns a design system used by 10+ product teams. Some teams use align-items: stretch for dynamic content, others use center for consistency. This leads to visual inconsistency in shared layouts. How would you architect a solution that enforces alignment semantics without stifling flexibility?

  3. 3

    We’re building a cross-platform UI framework (web, mobile web, native wrappers). How do you handle align-items in a way that abstracts browser inconsistencies while preserving expected behavior across platforms — especially when native components don’t support flexbox?

Follow-up Questions

  • What happens if you set align-items: center on a flex container with items of different heights?
  • How does align-items behave differently when the flex-direction is column instead of row?
  • Can you explain why some items might still appear misaligned even when align-items is set to stretch?