Rows with Flexbox
Halaman ini memerlukan browser terbaru (dengan dukungan SharedArrayBuffer). Silakan perbarui Chrome, Edge, Firefox, atau Safari ke versi terbaru.
English
Putting boxes in a row
- By default, boxes stack downward. Often you want them side by side.
- Flexbox is the easy way to do that.
- Put
display: flex;on the container — the box that holds the others — and its children line up in a row.

English
Spacing them out
- Once a box is
display: flex;, you control how its children spread. justify-content: space-between;pushes them apart, with gaps between.gap: 12px;adds an even space between every child.
English
<style>
.bar { display: flex; justify-content: space-between; }
.btn { background-color: #6c5; padding: 10px 16px; }
</style>
<div class="bar">
<span class="btn">Home</span>
<span class="btn">About</span>
<span class="btn">Contact</span>
</div>
English
Common mistakes
display: flexgoes on the container, not on the items.justify-contentspaces items along the row.
English
Now you try
display: flexgoes on the container, not the items.- Turn a box into a row, then spread its children out.
Jelajahi
Flexbox lays out a row
justify-content spaces items along the row; align-items across it.
Kesulitan 3/5 · 200 koin + bonus kecil pada penyelesaian pertama hari ini
Put the three boxes side by side. Add display: flex; to the .row rule.
Kesulitan 3/5 · 200 koin + bonus kecil pada penyelesaian pertama hari ini
Spread the boxes evenly across the row. Add justify-content: space-between; to the .row rule.
Kesulitan 3/5 · 200 koin + bonus kecil pada penyelesaian pertama hari ini
Make a row of tags with even gaps: give .tags display: flex; dan gap: 12px;.