Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Flexbox in Action | Layout Basics
Tailwind CSS for Web Development

book
Challenge: Flexbox in Action

Task

Complete the provided HTML structure by filling in the missing Tailwind CSS classes according to the layout requirements.

  • Parent div: Set the display to flex, and arrange the items in a column;

  • Child divs: Center the items horizontally and vertically within the container.

html

index.html

copy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Challenge: Flexbox Utilities - Task</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div
class="_____ _____ _____ _____ bg-red-100"
style="height: 200px"
>
<div class="p-4 bg-blue-500">Item 1</div>
<div class="p-4 bg-green-500">Item 2</div>
</div>
</body>
</html>

For the parent div,

  • Use flex to set an element to use Flexbox for its layout;

  • Use flex-col to place items in a column;

  • Use items-center to align items to the center;

  • Use justify-center to align items to the center.

html

index.html

copy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Challenge: Flexbox Utilities - Solution</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div
class="flex flex-col items-center justify-center bg-red-100"
style="height: 200px"
>
<div class="p-4 bg-blue-500">Item 1</div>
<div class="p-4 bg-green-500">Item 2</div>
</div>
</body>
</html>

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 4

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

some-alt