Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Gaps Between Items | Aligning and Distributing Elements
CSS Flexbox Foundations

bookGaps Between Items

When arranging items in a flex container, controlling the space between them is crucial for clean, readable layouts. The gap property offers a modern way to create consistent spacing between flex items, directly on the container.

Unlike using margins on individual items, which can lead to uneven or doubled spaces at the edges, gap ensures that spacing only appears between items, not before the first or after the last. This property is applied to the flex container, not the items themselves, and works in both row and column directions.

index.html

index.html

copy

Using gap in your flex layouts, as shown above, brings several benefits compared to adding margins to each item. With gap, you avoid the hassle of removing margins on the first or last items, keeping your code cleaner and your spacing more predictable. It also automatically adapts when your layout direction changes, such as switching from rows to columns. This makes your CSS easier to maintain and your layouts more consistent across different scenarios.

question mark

What are the advantages of using gap in Flexbox layouts?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 3

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Can you show me an example of how to use the `gap` property in a flex container?

What browsers support the `gap` property for flex layouts?

Are there any limitations or gotchas when using `gap` with flexbox?

Awesome!

Completion rate improved to 7.69

bookGaps Between Items

Deslize para mostrar o menu

When arranging items in a flex container, controlling the space between them is crucial for clean, readable layouts. The gap property offers a modern way to create consistent spacing between flex items, directly on the container.

Unlike using margins on individual items, which can lead to uneven or doubled spaces at the edges, gap ensures that spacing only appears between items, not before the first or after the last. This property is applied to the flex container, not the items themselves, and works in both row and column directions.

index.html

index.html

copy

Using gap in your flex layouts, as shown above, brings several benefits compared to adding margins to each item. With gap, you avoid the hassle of removing margins on the first or last items, keeping your code cleaner and your spacing more predictable. It also automatically adapts when your layout direction changes, such as switching from rows to columns. This makes your CSS easier to maintain and your layouts more consistent across different scenarios.

question mark

What are the advantages of using gap in Flexbox layouts?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 3
some-alt