Files
30-seconds-of-code/snippets/evenly-distributed-children.md
Angelos Chalaris 7e69307433 Update tags, expertise and descriptions across
Fix anything that was a bit out of place
2020-03-05 22:52:51 +02:00

767 B

title, tags
title tags
Evenly distributed children layout,intermediate

Evenly distributes child elements within a parent element.

<div class="evenly-distributed-children">
  <p>Item1</p>
  <p>Item2</p>
  <p>Item3</p>
</div>
.evenly-distributed-children {
  display: flex;
  justify-content: space-between;
}

Explanation

  1. display: flex enables flexbox.
  2. justify-content: space-between evenly distributes child elements horizontally. The first item is positioned at the left edge, while the last item is positioned at the right edge.

Note: Alternatively, use justify-content: space-around to distribute the children with space around them, rather than between them.

Browser support