Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Main Axis Alignment | Aligning and Distributing Elements
CSS Flexbox Foundations

bookMain Axis Alignment

The justify-content property in Flexbox lets you control how items are distributed along the main axis of your flex container. The main axis is determined by the flex-direction property. With justify-content, you can align items to the start or end, center them, or distribute extra space in different ways. The most common values are:

  • flex-start: items are packed toward the start of the main axis;
  • flex-end: items are packed toward the end;
  • center: items are centered along the main axis;
  • space-between: items are evenly distributed, with the first item at the start and the last at the end;
  • space-around: items are evenly distributed with equal space around them;
  • pace-evenly: items are distributed with equal space between, before, and after each item.

Each value creates a different visual effect, especially when the flex container is wider than the total width of the items.

index.html

index.html

copy

Using justify-content: space-between in the example above, the three items are stretched out so that the first item is flush with the start of the container, the last item is flush with the end, and the remaining space is evenly distributed between the items. This approach is useful when you want items to fill the available space without any gaps at the edges. Changing the value of justify-content will immediately affect the horizontal spacing and alignment of the flex items.

index.html

index.html

copy
question mark

Which of the following statements about the justify-content property in Flexbox are correct?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 1

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Suggested prompts:

Can you explain the difference between `space-between`, `space-around`, and `space-evenly`?

How does `justify-content` interact with `align-items` in Flexbox?

Can you provide a visual example of how these values affect layout?

Awesome!

Completion rate improved to 7.69

bookMain Axis Alignment

Stryg for at vise menuen

The justify-content property in Flexbox lets you control how items are distributed along the main axis of your flex container. The main axis is determined by the flex-direction property. With justify-content, you can align items to the start or end, center them, or distribute extra space in different ways. The most common values are:

  • flex-start: items are packed toward the start of the main axis;
  • flex-end: items are packed toward the end;
  • center: items are centered along the main axis;
  • space-between: items are evenly distributed, with the first item at the start and the last at the end;
  • space-around: items are evenly distributed with equal space around them;
  • pace-evenly: items are distributed with equal space between, before, and after each item.

Each value creates a different visual effect, especially when the flex container is wider than the total width of the items.

index.html

index.html

copy

Using justify-content: space-between in the example above, the three items are stretched out so that the first item is flush with the start of the container, the last item is flush with the end, and the remaining space is evenly distributed between the items. This approach is useful when you want items to fill the available space without any gaps at the edges. Changing the value of justify-content will immediately affect the horizontal spacing and alignment of the flex items.

index.html

index.html

copy
question mark

Which of the following statements about the justify-content property in Flexbox are correct?

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 1
some-alt