{ "$schema": "../schemas/code-crispies-module-schema.json", "id": "css-gradients", "title": "CSS Gradients", "description": "Create smooth color transitions with CSS gradients.", "difficulty": "intermediate", "lessons": [ { "id": "gradients-1", "title": "Linear Gradient", "description": "Gradients create smooth transitions between colors. The linear-gradient() function creates a gradient along a straight line.

Basic syntax:
background: linear-gradient(color1, color2);

By default, gradients flow from top to bottom.", "task": "Add a gradient background from coral to gold.", "previewHTML": "

Summer Sale

Up to 50% off

", "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .card { padding: 2rem; border-radius: 12px; color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.2); } .card h3 { margin: 0 0 8px; font-size: 1.5rem; } .card p { margin: 0; opacity: 0.9; }", "sandboxCSS": "", "codePrefix": ".card {\n ", "initialCode": "", "codeSuffix": "\n}", "solution": "background: linear-gradient(coral, gold);", "previewContainer": "preview-area", "validations": [ { "type": "contains", "value": "linear-gradient", "message": "Use linear-gradient()" }, { "type": "contains", "value": "coral", "message": "Include coral as the first color" }, { "type": "contains", "value": "gold", "message": "Include gold as the second color" } ] }, { "id": "gradients-2", "title": "Gradient Direction", "description": "Control the gradient direction by adding an angle or keyword before the colors.

Keywords: to right, to left, to bottom right
Angles: 45deg, 90deg, 180deg

background: linear-gradient(to right, blue, purple);
", "task": "Make the gradient flow from left to right using to right.", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 2rem; } .btn { padding: 1rem 2rem; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; color: white; cursor: pointer; }", "sandboxCSS": "", "codePrefix": ".btn {\n background: linear-gradient(", "initialCode": "", "codeSuffix": ", steelblue, mediumseagreen);\n}", "solution": "to right", "previewContainer": "preview-area", "validations": [ { "type": "contains", "value": "to right", "message": "Add to right to set the direction" } ] }, { "id": "gradients-3", "title": "Radial Gradient", "description": "The radial-gradient() function creates a gradient that radiates from a center point outward in a circular or elliptical pattern.

background: radial-gradient(circle, white, steelblue);

Add circle for a perfect circular gradient.", "task": "Create a radial gradient from white to steelblue.", "previewHTML": "
", "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 2rem; display: flex; justify-content: center; } .orb { width: 150px; height: 150px; border-radius: 50%; box-shadow: 0 8px 32px rgba(70, 130, 180, 0.4); }", "sandboxCSS": "", "codePrefix": ".orb {\n ", "initialCode": "", "codeSuffix": "\n}", "solution": "background: radial-gradient(circle, white, steelblue);", "previewContainer": "preview-area", "validations": [ { "type": "contains", "value": "radial-gradient", "message": "Use radial-gradient()" }, { "type": "contains", "value": "white", "message": "Start with white" }, { "type": "contains", "value": "steelblue", "message": "End with steelblue" } ] } ] }