Skip to main content
InterviewHubPRO
Section Overview
Q8

Question 8 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

16%
CSS3 & Modern Layouts (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

What is the difference between `flex-grow`, `flex-shrink`, and `flex-basis`?

junior LevelCode ExamplecssBasic

In Simple Words: Combined into the shorthand: flex: <grow> <shrink> <basis>.

  • flex-basis: The initial default size of the item along the main axis before free space is distributed (e.g., 200px or auto).
  • flex-grow: Proportion of available extra space the item absorbs when the container is larger than the sum of children. flex-grow: 2 absorbs twice as much remaining space as flex-grow: 1.
  • flex-shrink: Proportion the item shrinks when the container is too small to fit all children. flex-shrink: 0 prevents an item from ever shrinking below its flex-basis.
css
/* Grow to fill space, shrink if needed, initial basis 0 */
.flex-item {
  flex: 1 1 0; /* Shorthand for flex: 1 */
}