Flexbox, or the Flexible Box Layout, is a CSS layout model that allows you to design a layout structure more efficiently and predictably. It provides an easy way to align and distribute space among items in a container, even when their size is unknown or dynamic.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<title>Flex Examples</title>
</head>
<body>
<h2>Examples of Flexbox</h2>
<!-- Example 1: Basic Flexbox Layout -->
<h3>Basic Flexbox Layout</h3>
<div class="flex-container mb-3">
<div class="flex-example bg-light">Item 1</div>
<div class="flex-example bg-primary text-white">Item 2</div>
<div class="flex-example bg-secondary text-white">Item 3</div>
</div>
<!-- Example 2: Aligning Items -->
<h3>Aligning Items</h3>
<div class="d-flex justify-content-between align-items-center mb-3" style="height: 100px;">
<div class="flex-example bg-warning">Align Top</div>
<div class="flex-example bg-info">Align Center</div>
<div class="flex-example bg-success">Align Bottom</div>
</div>
<!-- Example 3: Responsive Flexbox -->
<h3>Responsive Flexbox</h3>
<div class="d-flex flex-wrap">
<div class="flex-example bg-danger" style="flex: 1 1 100px;">Responsive Item 1</div>
<div class="flex-example bg-dark text-white" style="flex: 2 1 200px;">Responsive Item 2</div>
<div class="flex-example bg-light" style="flex: 1 1 100px;">Responsive Item 3</div>
</div>
<!-- Example 4: Changing Order -->
<h3>Changing Order</h3>
<div class="d-flex">
<div class="flex-example bg-success" style="order: 2;">Item A</div>
<div class="flex-example bg-danger" style="order: 1;">Item B</div>
<div class="flex-example bg-primary text-white" style="order: 3;">Item C</div>
</div>
<!-- Example 5: Justify Content -->
<h3>Justify Content</h3>
<div class="d-flex justify-content-around mb-3">
<div class="flex-example bg-light">Justified Item 1</div>
<div class="flex-example bg-primary text-white">Justified Item 2</div>
<div class="flex-example bg-secondary text-white">Justified Item 3</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>