Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Wrapping Items with flex-wrap | Understanding Flexbox Basics
CSS Flexbox Foundations

bookWrapping Items with flex-wrap

Flexbox layouts offer powerful control over how items are arranged within a container. By default, flex items are laid out in a single line, but sometimes the space is not enough to fit all items side by side. The flex-wrap property lets you control whether items stay on one line or wrap onto multiple lines or columns. It accepts three values: nowrap, wrap, and wrap-reverse.

  • With nowrap (the default), items will try to fit onto a single line, potentially overflowing the container;
  • Using wrap allows items to move onto new lines when they run out of space, making the layout more responsive;
  • The wrap-reverse value is similar to wrap, but it places new lines in the opposite direction, which can be useful for certain visual effects or design requirements.

Choose nowrap when you want a strict, single-line layout, and use wrap or wrap-reverse when you want your layout to adapt and prevent overflow.

index.html

index.html

copy

When you enable wrapping with flex-wrap: wrap, items that cannot fit on the main axis will automatically move to a new line. In the example above, the container is only 180px wide, but each item is 80px wide plus margins. This means only two items can fit per line, so the remaining items are pushed onto the next line. This wrapping behavior keeps your layout neat and prevents items from overflowing or being squished.

In contrast, if you used flex-wrap: nowrap, all four items would try to fit on one line, causing overflow or shrinking. Wrapping is especially helpful for responsive designs, where the container size may change on different devices.

index.html

index.html

copy
question mark

What happens when you set a flex container's flex-wrap property to 'nowrap'?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Suggested prompts:

Can you explain the difference between `wrap` and `wrap-reverse` with an example?

When should I use `flex-wrap: nowrap` instead of `wrap`?

How does `flex-wrap` affect responsive design?

Awesome!

Completion rate improved to 7.69

bookWrapping Items with flex-wrap

Свайпніть щоб показати меню

Flexbox layouts offer powerful control over how items are arranged within a container. By default, flex items are laid out in a single line, but sometimes the space is not enough to fit all items side by side. The flex-wrap property lets you control whether items stay on one line or wrap onto multiple lines or columns. It accepts three values: nowrap, wrap, and wrap-reverse.

  • With nowrap (the default), items will try to fit onto a single line, potentially overflowing the container;
  • Using wrap allows items to move onto new lines when they run out of space, making the layout more responsive;
  • The wrap-reverse value is similar to wrap, but it places new lines in the opposite direction, which can be useful for certain visual effects or design requirements.

Choose nowrap when you want a strict, single-line layout, and use wrap or wrap-reverse when you want your layout to adapt and prevent overflow.

index.html

index.html

copy

When you enable wrapping with flex-wrap: wrap, items that cannot fit on the main axis will automatically move to a new line. In the example above, the container is only 180px wide, but each item is 80px wide plus margins. This means only two items can fit per line, so the remaining items are pushed onto the next line. This wrapping behavior keeps your layout neat and prevents items from overflowing or being squished.

In contrast, if you used flex-wrap: nowrap, all four items would try to fit on one line, causing overflow or shrinking. Wrapping is especially helpful for responsive designs, where the container size may change on different devices.

index.html

index.html

copy
question mark

What happens when you set a flex container's flex-wrap property to 'nowrap'?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4
some-alt