Skip to content
Back to Concepts
CSS UniverseTrack 5: Visual StylingBackgrounds & Parallax
Visual Styling · Track 5Core Concept 18

Backgrounds, Gradients & Multi-Layers

Every element in CSS is a canvas that can stack multiple layers: transparent dot matrices, rich linear & conic gradients, and responsive background images with pure CSS fixed parallax scrolling.

1. The Mental Model: Stack of Transparent Glass Sheets

In CSS, background-image accepts a comma-separated list of values. Think of each item as a transparent glass sheet stacked on top of your desk:

Sheet 1 (Topmost / Closest to Eye)

Pattern overlay or semi-transparent noise dots. Anything transparent here reveals the sheet underneath.

Sheet 2 (Middle)

Gradient or hero illustration. First declared layer renders on top of later declared layers!

The Desk Surface (Bottom)

background-color is always the fallback bottom surface beneath all image layers.

2. The 3 Gradient Types in Modern CSS

Linear Gradient

Transitions colors along a straight ray defined by an angle (e.g. 90deg) or directional keywords (to bottom right).

linear-gradient(45deg, #ec4899, #8b5cf6)

Radial Gradient

Radiates outward from a central anchor point in concentric circles or ellipses. Perfect for spot lights, badges, and glow orbs.

radial-gradient(circle at center, #8b5cf6, #1e1b4b)

Conic Gradient

Rotates colors around a center pin like a radar sweep or color wheel. Build pure CSS pie charts and circular progress bars!

conic-gradient(from 0deg, #ec4899, #3b82f6)

3. Interactive Studio: Gradient Mixer & Multi-Layer Engine

Angle / Rotation135°
CSS Background Code
background: radial-gradient(circle, rgba(255,255,255,0.15) 1px, transparent 1px), linear-gradient(135deg, #ec4899 0%, #8b5cf6 50%, #3b82f6 100%);
LINEAR CANVAS2 Layers Active

Pure CSS Hero Card

Zero external image files required. Pure mathematical GPU rasterization renders instantaneously on any screen resolution.

Pure CSS Parallax in 1 Line

Add background-attachment: fixed; to make an image stick to the browser viewport while the rest of the document scrolls past it. No JavaScript event listeners or scroll lagging!

First-Year Student Traps: Backgrounds

  • 1.The Background Shorthand Slash Syntax: In the shorthand background property, you must separate position and size with a slash: background: url('bg.jpg') center / cover no-repeat;. Leaving out the slash makes the browser drop the size entirely!
  • 2.Mobile iOS Fixed Background Bug: background-attachment: fixed often malfunctions or triggers heavy repaint stutters in Safari on iOS devices. The modern workaround is a fixed pseudo-element with position: fixed; inset: 0; z-index: -1;.
  • 3.The Missing Fallback Color: Never declare a dark text hero over a dark image without adding a matching background-color: #0f172a fallback. If the client has a 3G network or ad-blocker blocking images, the user will see black text on white default background!
Next Masterclass

Borders, Outlines & Geometric Shapes

Master 8-value border-radius blobs, outline offsets for accessibility, and border-image ribbons.

Continue to Concept 19