انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents
Robo Web: home
0. Lab tour1
1. HTML: the page's content7
2. CSS: the page's look6
3. JavaScript: the actions7
4. The project: the to-do list3
5. Pro CSS: shadows and movement5
6. Arrays and building the page with code3
7. Events and forms3
8. Objects and time3
9. Canvas: drawing and games3
10. The final project: the memory game3

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: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.

🌐 A bar at the top of the page
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:The page in Robo Web
✍️ Practise
Flexbox.
✍️ Practise here in the lessonor open the lab in a new page ↗
✍️ Practise
Fix it: flex is in the wrong place.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

Three boxes in one row.

👀 Show the solution
🌐 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:The page in Robo Web

Result: the boxes are side by side.

Medium

The same boxes right in the middle.

👀 Show the solution
🌐 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: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
🌐 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:The page in Robo Web

Result: a column of three.

Finished the lesson? Mark it so your progress counts.