Flexbox: side by side
Section 2: CSS: the page's lookLesson 2.3 · ⏱ 8 min
display: flex on the box around them puts what is inside side by side, and gap is the space between them.
HTML
<div class="row">
<div class="card">🤖</div>
<div class="card">🚀</div>
<div class="card">⭐</div>
</div>
CSS
body { font-family: Tahoma; }
.row {
display: flex;
gap: 16px;
}
.card {
background: #E8F0FF;
font-size: 40px;
padding: 20px;
border-radius: 14px;
text-align: center;
}
🖥️ The page in Robo Web:

📌 Another example: a bar at the top of the page
A logo on one side, and links on the other side: justify-content: space-between.
HTML
<nav class="bar">
<b>🤖 Robo</b>
<div class="links">
<a href="#">Home</a>
<a href="#">Lessons</a>
<a href="#">Contact</a>
</div>
</nav>
CSS
body { font-family: Tahoma, sans-serif; }
.bar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 18px;
background: #1B2350;
color: white;
}
.links { display: flex; gap: 14px; }
.links a { color: #FFBF00; }
🖥️ The page in Robo Web:

✍️ Practise
Flexbox.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
✍️ Practise
Fix it: flex is in the wrong place.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
🎯 Challenge yourself
Easy
Three boxes in one row.
👀 Show the solution🙈 Hide the solution
HTML
<div class="row">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
CSS
.row { display: flex; gap: 10px; }
.row div { padding: 20px; background: gold; }
🖥️ The page in Robo Web:

Result: the boxes are side by side.
Medium
The same boxes right in the middle.
👀 Show the solution🙈 Hide the solution
HTML
<div class="row">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
CSS
.row { display: flex; gap: 10px; justify-content: center; }
.row div { padding: 20px; background: gold; }
🖥️ The page in Robo Web:

Result: in the middle of the page.
Hard
The boxes on top of each other: flex-direction: column.
👀 Show the solution🙈 Hide the solution
HTML
<div class="row">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
CSS
.row { display: flex; flex-direction: column; gap: 10px; }
.row div { padding: 20px; background: gold; }
🖥️ The page in Robo Web:

Result: a column of three.

