← Back to Overview Chapter 07: Effects & Shadows

1. Linear, Radial & Conic Gradients

CSS Gradients render smooth transitions between colors without bitmap assets.

Linear Gradient 135deg multi-stop
Radial Gradient Circle at center
Conic Gradient Color wheel angle

Gradient Border Card

Achieved using a pseudo-element with inset: -3px; and a vibrant gradient background sitting behind the card body.

.linear { background: linear-gradient(135deg, #667eea, #764ba2); }
.radial { background: radial-gradient(circle at center, #f59e0b, #dc2626); }
.conic  { background: conic-gradient(from 0deg, red, yellow, green, cyan, blue, red); }

2. Crucial Comparison: box-shadow vs. drop-shadow()

Notice the vital difference below: box-shadow casts a shadow on the rectangular bounding box, whereas filter: drop-shadow() traces the exact non-transparent contours of the SVG / PNG!

Palette Box Shadow
box-shadow
Shadows the rectangular container
Palette Drop Shadow
filter: drop-shadow()
Traces the transparent SVG shape!
/* Bad for transparent icons: shadows rectangle */
.icon { box-shadow: 10px 10px 15px rgba(0,0,0,0.4); }

/* Best for transparent icons: shadows contour! */
.icon { filter: drop-shadow(10px 10px 10px rgba(0,0,0,0.4)); }

3. Modern Glassmorphism (Frosted Glass)

Combine semi-transparent backgrounds with backdrop-filter: blur(14px); to create realistic frosted glass UI panels.

Gem

Glassmorphism Card

Background elements are dynamically blurred behind this container.

.glass-card {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

4. Interactive CSS Filter Playground

Click the buttons below to apply hardware-accelerated CSS filters directly to the OpenMoji illustration!

Rainbow Filter Target
filter: none;
.target { filter: none; }

5. Gradient Masking & OKLCH Color Space (#22, #30)

mask-image: Apply alpha masks using gradients to create smooth fade-out edges.
oklch(): Perceptually uniform color space where hue changes preserve constant perceived luminance.

mask-image Fade-Out Mask:

Fade-out Text Scroller

Using mask-image: linear-gradient(to bottom, black 50%, transparent 100%) gracefully fades out overflowing content at the bottom without needing absolute positioned gradient overlays!

oklch() Perceptually Uniform Palette:
oklch(30°)
oklch(140°)
oklch(250°)
All swatches share identical perceived lightness (0.65) and chroma (0.24), varying only in hue angle!
/* Fade-out alpha mask */
.fade-box {
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

/* Modern perceptually uniform colors */
.swatch {
    background-color: oklch(0.65 0.24 140); /* Lightness, Chroma, Hue */
}
Fixed 🏠