Files
30-seconds-of-code/snippets/evenly-distributed-childs.md
2018-02-28 13:18:14 +02:00

1.1 KiB

Evenly distributed childs

Evenly distributed childs within the alignment container

HTML

<div class="evenly-distributed-childs">
  <p class="child">Item1</p>
  <p class="child">Item2</p>
  <p class="child">Item3</p>
</div>

CSS

.evenly-distributed-childs {
  display: flex;
  width: 300px;
  justify-content: space-between;
}

Demo

Item1

Item2

Item3

<style> .snippet-demo__evenly-distributed-childs { display: flex; width: 100%; justify-content: space-between; } </style>

Explanation

  1. display: flex enables flexbox.
  2. justify-content: space-between evenly distributes childs in the line.

First item will be on the start line, last item on the end line

Browser support

⚠️ Needs prefixes for full support.