{
"$schema": "../../schemas/code-crispies-module-schema.json",
"id": "flexbox",
"title": "CSS Flexbox",
"description": "Beherrsche das flexible Box-Layout-Modell für moderne responsive Designs",
"difficulty": "intermediate",
"lessons": [
{
"id": "flexbox-1",
"title": "Container",
"description": "Vor Flexbox erforderten selbst einfache Layouts Floats, Positionierungs-Hacks oder tabellenbasierte Layouts. Flexbox (Flexible Box Layout) revolutionierte CSS, indem es ein eindimensionales Layout-System speziell für Platzverteilung und Inhaltsausrichtung bereitstellte.
So funktioniert es: Wenn du display: flex auf ein Element setzt, wird es zum Flex-Container. Seine direkten Kinder werden automatisch zu Flex-Items, die entlang einer Hauptachse fließen (standardmäßig horizontal). Diese eine Eigenschaft verwandelt gestapelte Block-Elemente in eine horizontale Reihe.
Die zwei Achsen:
• Hauptachse – Die primäre Richtung, in der Items fließen (row = links→rechts)
• Querachse – Senkrecht zur Hauptachse (row = oben→unten)
.nav {\n display: flex;\n}",
"task": "Dieses Navigationsmenü stapelt sich vertikal. Füge display: flex hinzu, um die Links horizontal anzuordnen.",
"previewHTML": "",
"previewBaseCSS": "body { font-family: system-ui, sans-serif; margin: 0; } .nav { background: #1a1a2e; padding: 1rem; } .nav a { color: white; text-decoration: none; padding: 8px 1rem; border-radius: 4px; } .nav a:hover { background: rgba(255,255,255,0.1); }",
"sandboxCSS": "",
"codePrefix": ".nav {\n ",
"initialCode": "",
"codeSuffix": "\n}",
"solution": "display: flex;",
"previewContainer": "preview-area",
"validations": [
{
"type": "property_value",
"value": { "property": "display", "expected": "flex" },
"message": "Setze display: flex"
}
]
},
{
"id": "flexbox-2",
"title": "Gap",
"description": "Die gap-Eigenschaft fügt konsistenten Abstand zwischen Flex-Items hinzu, ohne dass Margins nötig sind. Sie erzeugt nur Platz zwischen Items, nicht an den Rändern.",
"task": "Füge gap: 1rem hinzu, um die Navigationslinks gleichmäßig zu verteilen.",
"previewHTML": "",
"previewBaseCSS": "body { font-family: system-ui, sans-serif; margin: 0; } .nav { background: #1a1a2e; padding: 1rem; display: flex; } .nav a { color: white; text-decoration: none; padding: 8px 1rem; border-radius: 4px; background: rgba(255,255,255,0.1); }",
"sandboxCSS": "",
"codePrefix": ".nav {\n ",
"initialCode": "",
"codeSuffix": "\n}",
"solution": "gap: 1rem;",
"previewContainer": "preview-area",
"validations": [
{
"type": "property_value",
"value": { "property": "gap", "expected": "1rem" },
"message": "Setze gap: 1rem"
}
]
},
{
"id": "flexbox-3",
"title": "Justify Content",
"description": "justify-content verteilt Items entlang der Hauptachse. Häufige Werte: