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

Can you use Flexbox and Grid together in the same layout?

Using Flexbox and Grid Together

Yes, you can use Flexbox and Grid together in the same layout. While Grid is ideal for defining the overall page structure, Flexbox can be used inside individual grid items to control alignment and spacing of content.

Key Points
  1. 1

    Grid handles two-dimensional layouts, defining rows and columns for the overall structure.

  2. 2

    Flexbox can be applied to items inside a grid cell to arrange content along a single axis.

  3. 3

    This combination allows precise page layouts with flexible inner components.

  4. 4

    Nested Flexbox inside Grid items is useful for menus, cards, toolbars, or any component that needs dynamic spacing and alignment.

Example: Grid with Flexbox Inside

In this example, the .grid-container defines two columns, and each .flex-item uses Flexbox to arrange its inner elements horizontally with equal spacing.

Difficulty: 3/10
Topics: Flexbox layout, CSS Grid layout, Nested layout composition

Scenario Questions

0-2 years experience
  1. 1

    You're building a card component with a header, image, and two buttons below it — the buttons need to be side-by-side and evenly spaced. How would you structure the CSS using both Grid and Flexbox?

  2. 2

    If you set display: grid on a parent and then try to use justify-content: center on a child that's set to display: flex, what happens? Can you explain why?

2-5 years experience
  1. 1

    A dashboard layout uses CSS Grid for the overall structure, but one of the sidebar panels has dynamic content that overflows horizontally. The team tried using Flexbox inside the grid cell to fix it, but now the content wraps unexpectedly. What’s likely going wrong, and how would you debug it?

  2. 2

    You inherited a component where Grid is used for the main layout, but every inner section uses Flexbox for alignment — the code feels bloated. When would you consider simplifying this by removing one of the systems, and when would you keep both?

5-8 years experience
  1. 1

    You're designing a responsive admin panel where the main content area uses Grid for column layout, but each card inside needs to align text and icons vertically in a way that adapts to variable content height. How would you architect this without creating layout thrashing or unnecessary nesting?

  2. 2

    A component library uses Grid for the root layout and Flexbox for internal alignment, but in RTL mode, some elements misalign. How would you investigate and fix this across multiple components without duplicating logic?

8+ years experience
  1. 1

    Your team is migrating a legacy UI from float-based layouts to modern CSS. Some components mix Grid and Flexbox inconsistently across 50+ pages. How would you establish a design system standard for when to use each, and how would you enforce it at scale?

  2. 2

    You’re designing a global layout system for a multinational product with heavy localization needs. Grid handles the page structure, but text containers must adapt to varying line lengths and icon sizes across languages. How do you ensure maintainability and performance as the number of localized components grows into the hundreds?

Follow-up Questions

  • How do you decide whether to use Grid or Flexbox for the outer container?
  • What happens if you apply Flexbox properties to a grid item?
  • Can nesting too many Flexbox containers inside Grid cells hurt performance?