Examples

Pure CSS diagonal optical illusion with parallel lines distorted on a yellow background, revealed on hover.

A pure CSS diagonal optical illusion that distorts parallel lines without JavaScript. Combines repeating-linear-gradient grid stripes with rotated conic-gradient elements on body::before and body::after pseudo-elements. Hovering transitions the @property --color variable to transparent, removing the visual interference to demonstrate that all diagonal lines are strictly parallel.

CSS
Optical Illusion Pure CSS Animated Property Hover Reveal
Browsers:
Chrome Chrome Edge Edge Safari Safari Firefox Firefox
Payload: 1 kB
Best for: Interactive Demos, Hero Backgrounds, Creative Canvas
Loading...
/*
optical effect
The diagonal black lines are parallel, but they look like they are not. Mouse over to reveal
*/
@property --color {
  syntax: '<color>';
  initial-value: #f00;
  inherits: true;
}

body {
  --color: #000;
  margin: 0;
  font-size: 1vmax;
  height: 100vh;
  overflow: hidden;
  transition: --color 1s;
  background: #fd5;
}

body:hover {
  --color: #0000;
}

body::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: 300em;
  height: 300em;
  background:
    repeating-linear-gradient(#0000 0 18em, #000 0 20em),
    conic-gradient(at 1em 8em, #0000 75%, var(--color) 0) 0 -5em / 2em 20em;
  transform: skewY(-45deg);
}

body::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: 300em;
  height: 300em;
  background:
    repeating-linear-gradient(#0000 0 18em, #000 0 20em),
    conic-gradient(at 1em 8em, #0000 75%, var(--color) 0) 0 -5em / 2em 20em;
  transform: rotate(90deg) skewY(45deg) translate(0.25em, 12em);
}
  • Colors / Themes: Change canvas color via background: #fd5 on body. Adjust illusion tile color --color: #000 and initial value initial-value: #f00 inside @property --color. Tweak hover reveal state via --color: #0000.
  • Gradients & Visual Effects: Modify grid line spacing by editing repeating-linear-gradient(#0000 0 18em, #000 0 20em) stop offsets. Alter distortion block positioning through conic-gradient(at 1em 8em, #0000 75%, var(--color) 0) 0 -5em / 2em 20em inside pseudo-elements.
  • Sizing, Layout & Scales: Change viewport scale density via font-size: 1vmax on body. Adjust tilt severity by modifying transform: skewY(-45deg) on body::before and transform: rotate(90deg) skewY(45deg) on body::after.
Pure CSS Cafe Wall optical illusion with parallel lines distorted by conic gradients, revealed on hover.

An optical illusion rendered entirely in CSS using zero HTML elements. Employs pseudo-elements with skewed repeating-linear-gradient and conic-gradient layers to create the perception of non-parallel lines. Hovering over the viewport transitions the @property --color variable to transparent, instantly disabling the visual distortion and revealing parallel horizontal lines.

CSS
Optical Illusion Pure CSS Animated Property Hover Reveal
Browsers:
Chrome Chrome Edge Edge Safari Safari Firefox Firefox
Payload: 1 kB
Best for: Interactive Demos, Hero Backgrounds, Creative Canvas
Loading...
/*
optical effect
The black lines are parallel, but they look like they are not. Mouse over to reveal
*/
@property --color {
  syntax: '<color>';
  initial-value: #f00;
  inherits: true;
}

body {
  --color: #f55;
  margin: 0;
  font-size: 1vmax;
  height: 100vh;
  overflow: hidden;
  transition: --color 1s;
}

body:hover {
  --color: #0000;
}

body::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: 300em;
  height: 300em;
  background:
    repeating-linear-gradient(#0000 0 18em, #000 0 20em),
    conic-gradient(at 1.25em 10em, #0000 75%, var(--color) 0) 0 -6em / 2.5em 20em;
  transform: skewY(-45deg);
}

body::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: 300em;
  height: 300em;
  background:
    repeating-linear-gradient(#0000 0 18em, #000 0 20em),
    conic-gradient(at 1.25em 10em, #0000 75%, var(--color) 0) 0 -6em / 2.5em 20em;
  transform: rotate(90deg) skewY(45deg) translate(0.25em, 12em);
}
  • Colors / Themes: Change distortion tile colors by modifying --color: #f55 on body and initial-value #f00 inside @property --color. Update hover transparency target --color: #0000 to alter reveal contrast.
  • Gradients & Visual Effects: Adjust line frequency by tweaking repeating-linear-gradient(#0000 0 18em, #000 0 20em) offsets inside body::before and body::after. Modify pattern angles via conic-gradient(at 1.25em 10em, ...) tile dimensions / 2.5em 20em.
  • Sizing, Layout & Scales: Rescale pattern density by altering font-size: 1vmax on body. Tweak illusion distortion strength by adjusting skew angles transform: skewY(-45deg) and skewY(45deg).
Grid of three textured teal cards featuring shifted 3D overlapping backdrop layers on a base64 speculary-lit SVG noise background.

This lightweight grid layout styles nested cards with an organic paper feel entirely through vector code. It utilizes a base64-encoded SVG filter featuring specular lighting and turbulence to inject a matte noise texture over solid colors. By applying an offset ::after pseudo-element rotated by 8deg with mix-blend-mode: overlay, each card gains a shifted tactile depth layer without heavy graphics.

SVG HTML/Pug CSS/Sass
SVG Specular Noise Layered Overlay Shifting Conic Gradient BG
Browsers:
Chrome Chrome 105+ Edge Edge 105+ Firefox Firefox 103+ Safari Safari 16+
Interactive procedural graph notebook paper background generated entirely with multiple stacked CSS gradients and adjustable gap sizing.

An interactive graph notebook paper pattern drawn entirely via stacked, layered CSS gradients. By combining major and minor linear grid lines, radial cross masks, and corner border offsets, it forms a fully customizable procedural background. It utilizes CSS @property Houdini variables to smoothly transition gap sizing updates, alongside dynamic theme and color hue tuning.

HTML CSS JavaScript
Procedural Gradients Houdini Transition Adaptive Themes
Browsers:
Chrome Chrome 110+ Edge Edge 110+ Firefox Firefox 128+ Safari Safari 16.4+
Interactive Café Wall optical illusion built entirely with pure CSS conic gradients, shifting row positions on hover to reveal parallel lines.

An interactive pure-CSS representation of the classic Café Wall optical illusion. Built with zero HTML markup, the layout layers gray linear separators and offset black-and-white conic gradients to create a pattern where perfectly parallel lines appear tilted. Hovering over the page realigns the checkerboard columns to immediately debunk the cognitive illusion.

CSS
Optical Illusion Conic Gradients Zero-HTML Layout
Browsers:
Chrome Chrome 69+ Edge Edge 79+ Firefox Firefox 83+ Safari Safari 12.1+
Pure CSS Ehrenstein optical illusion featuring aligned linear segments that trick the brain into perceiving non-existent white circular discs.

An elegant pure-CSS implementation of the classic Ehrenstein optical illusion. Requiring zero HTML, the stylesheet utilizes offset conic-gradient() coordinates to render a repeating grid of vertical and horizontal lines. When looking at the resulting pattern, the human visual system automatically completes the missing intersections, perceiving non-existent bright white discs.

CSS
Optical Illusion Conic Gradients Zero-HTML Layout
Browsers:
Chrome Chrome 69+ Edge Edge 79+ Firefox Firefox 83+ Safari Safari 12.1+
Webpage layout featuring a vintage airmail envelope border with diagonal red and blue stripes using CSS gradients

This is a Retro Airmail Envelope Border. It wraps a container with continuous diagonal red and blue stripes. Its function is to provide a nostalgic, thematic framing for content without relying on external raster image assets.

CSS
Gradient Border CSS Variables Vintage Style
Browsers:
Chrome Chrome 108+ Edge Edge 108+ Firefox Firefox 101+ Safari Safari 15.4+
Black and white optical illusion geometric pattern generated with pure CSS gradients

This is an Optical Illusion CSS Background Pattern. It generates a complex, interlocking geometric tessellation using only mathematical gradient overlays. Its function is to provide a visually striking, lightweight background texture without requiring external image assets.

CSS
Pure CSS Gradient Overlays Minimal Footprint
Browsers:
Chrome Chrome 69+ Edge Edge 79+ Firefox Firefox 83+ Safari Safari 12.1+
Black and white optical illusion pattern featuring a central circle that appears to pulse against a striped background, created with pure CSS gradients

This is a Pulsing Circle Optical Illusion. It generates a static, high-contrast geometric pattern that exploits peripheral vision to create a false sense of motion. Its function is to serve as a lightweight, visually arresting background or artistic centerpiece using only a handful of CSS properties and zero JavaScript.

CSS
Optical Illusion Pure CSS No Animation
Browsers:
Chrome Chrome 69+ Edge Edge 79+ Firefox Firefox 83+ Safari Safari 12.1+
Two colored boxes (yellow and blue) moving horizontally across a black and white striped background, demonstrating the stepping feet illusion.

This is the Stepping Feet Optical Illusion. It demonstrates how high-contrast patterns interfere with human motion perception. Two colored blocks move at identical, constant speeds, yet appear to stagger and “step” like feet. A hover interaction removes the background grid to expose the mathematical reality of their parallel movement.

CSS
Pseudo-elements Keyframe Animation Linear Gradients
Browsers:
Chrome Chrome 105+ Edge Edge 105+ Firefox Firefox 121+ Safari Safari 16.4+
Minimalist dark-mode navigation menu with large serif typography and a background pattern that shifts based on the hovered menu item.

This is a Cinematic Parallax Reactive Navigation Menu. It synchronizes large-scale typographical navigation with multi-layered background shifts. Its function is to transform a standard menu into a high-end atmospheric gateway for editorial or premium portfolio websites, using user interaction to drive the visual narrative.

HTML CSS JavaScript
Background Shifting Parallax Interaction State-Driven Styling
Browsers:
Chrome Chrome 80+ Edge Edge 80+ Firefox Firefox 75+ Safari Safari 13.1+
A UI background starting as white at the top with gray grid lines, fading into a vibrant teal-to-purple gradient at the bottom.

This Fading Grid Gradient Background creates a clean, architectural aesthetic suitable for SaaS landing pages or documentation sites. It features a technical vertical grid pattern that gently dissolves into a vibrant teal-and-purple gradient at the bottom. The effect mimics a “horizon” line, adding depth and structure to an otherwise flat page without using any images.

HTML CSS
CSS Masks Stacked Gradients Pattern Generation Responsive Background
Browsers:
Chrome Chrome 80+ Edge Edge 80+ Firefox Firefox 53+ Safari Safari 15.4+
CSS-Only Pattern: Circles

An elegant, geometrically complex background in blue tones that looks like a vector illustration but weighs only a few bytes and scales easily.

See the Pen CSS-Only Pattern: Circles.

Scalable CSS Radial Gradient Pattern

A pure CSS pattern created by overlaying five radial-gradient declarations on a single element. The main feature is that all ring sizes and their count depend on a couple of CSS variables, making the pattern fully scalable using calc().

Intersecting Diagonals Pattern

A pattern generated with just one background property, showcasing advanced use of CSS gradients and background-size to create a complex, repeating texture, with flexible customization via custom CSS properties.

CSS-Only Pattern - Waves

A lightweight and effective demo showcasing a complex background pattern created entirely with pure CSS gradients. The result is a dynamic, scalable background without the need for any image files or JavaScript.

See the Pen CSS-Only Pattern - Waves.

Squiggle Waves Tessellated Pattern – Pure CSS

A complex geometric CSS pattern constructed from multiple layers of conic-gradient and radial-gradient. This seamless background offers a scalable, vector-quality tessellation design that is fully controllable via CSS variables for easy customization.

3D Chocolate Bar Tessellated Pattern – No Div – Pure CSS

A sophisticated geometric CSS background created with layered conic gradients and custom properties for seamless styling. This performant pattern is fully scalable and provides a lightweight, code-based alternative to images for modern UI/UX design.

Chocolate Wafer CSS Background

A sophisticated striped background pattern built with pure CSS using the linear-gradient hard-stop technique. This lightweight snippet offers a high-performance, responsive UI solution that mimics complex textures without the need for external image assets.

Knowledge Base

Frequently Asked Questions

Common questions about integration, browser support, and customizing these components.

Why use CSS gradient patterns instead of SVG or image-based backgrounds?
CSS gradient patterns require zero HTTP requests and scale vectorially across all resolutions without file-size overhead. Unlike raster images, they adapt to container dimensions automatically and can be themed in real-time using CSS Custom Properties without reloading assets.
How do gradient-based background patterns affect rendering performance?
Gradient patterns are rasterized by the browser’s rendering engine as bitmap textures, so layering too many stops per gradient or stacking more than 4–5 gradient layers can increase paint time. For complex textures, consider using the CSS Paint API (Houdini) to offload pattern generation to a dedicated worklet thread.
How can I make background patterns responsive without media queries?
Use relative units like % or vw in background-size combined with CSS Container Queries to scale the pattern unit proportionally to the parent container. This ensures seamless pattern density across viewports without hardcoded breakpoints.
How to maintain sufficient color contrast when placing content over patterned backgrounds?
Always define a solid background-color fallback behind the gradient pattern to guarantee readability. Use the contrast-color() function or OKLCH color space to programmatically adjust text color against the dominant pattern hue.
What is the best fallback strategy for browsers that don’t support advanced gradient syntax?
Layer a fully opaque background-color as the first declaration, then override it with the gradient pattern. Browsers that ignore the gradient will display the solid color, ensuring content remains readable without feature detection overhead.
Can CSS gradient patterns be animated efficiently without causing layout thrash?
Yes — animate gradients by transitioning CSS Custom Properties registered with @property, which bypasses main-thread repaints. Avoid animating background-size or background-position directly, as these trigger layout recalculations on every frame.