Most demos need a newer browser

They use :has() and container queries. Update your browser, or on an iPhone update iOS to 16.4 or later.

CSS Layout Examples

Layout is the largest group here because it covers both where things sit and how they behave as the page scrolls or the window changes size. Grid and flexbox do the arranging, aspect-ratio holds proportions steady, position: sticky pins an element while its container scrolls past, and scroll-driven animation ties motion to scroll position with no script involved.

The range runs from small self-contained pieces, such as aspect-ratio boxes and split panels, up to whole-page behavior like parallax scenes, reveal-on-scroll sections, and carousels that snap. Scroll-driven animation is the newest technique in this group, so those pages carry browser support notes worth reading before shipping.

No examples match these filters yet. Turn on another level or pick another category.

One page layout at three widths, redrawn by its template

Your browser can't run this demo

It needs :has(), which this browser doesn't support yet. It works in Chrome 105+, Edge 105+, Firefox 121+ and Safari 15.4+.

Needs :has()

.ga-page {
  display: grid;
  grid-auto-columns: 1fr;
  gap: .4rem;
  grid-template-areas:
    "header"
    "nav"
    "main"
    "aside"
    "footer";
    "header header"
    "nav    nav"
    "main   aside"
    "footer footer";
    "header header header header"
    "nav    main   main   aside"
    "footer footer footer footer";
}
header
nav
main
aside

Grid Template Areas

Beginner

Radios switch a five-area page layout between one, two and four columns by changing only the parent's grid-template-areas string.

Frosted glass over moving color

Glass card

Frosted glass

A blur, a thin tint and a bright edge. The color behind stays, only softer.

  • blur 16px
  • saturate 180%

Glassmorphism Card

Beginner

A frosted glass card over moving gradients, using backdrop-filter with a dark tint that keeps white text readable.

A quote, its marks and its credit

Sample quotation text goes here.

Author name, Title of the work

Blockquote Styles

Beginner

A quotation with large generated marks, a styled credit and variants for pull quotes, testimonial cards and nested quotes.

Press the button, latch the toggle

Your browser can't run this demo

It needs :has(), which this browser doesn't support yet. It works in Chrome 105+, Edge 105+, Firefox 121+ and Safari 15.4+.

Needs :has()

Focus timer

25:00

Neumorphism

Intermediate

Soft UI controls built from paired box-shadow values, where a raised button presses into the surface on :active.

Two ways to sit a title on the line

Your browser can't run this demo

It needs :has() and color-mix(), which this browser doesn't support yet. It works in Chrome 111+, Edge 111+, Firefox 121+ and Safari 16.2+.

Needs :has() and color-mix()

Title position
Delivery address

fieldset + legend

Plan details

Storage
20 GB
Members
5 seats
Billing
Monthly

heading + ::before and ::after lines

Text on Border

Beginner

A heading that sits on a box's border line, built with a fieldset legend or flex pseudo-elements.

Three places vertical text earns its keep

Section 02

Setup guide

The label runs up the edge, so it names the section without using a line of the card.

Edge label, sideways-lr
Field guide Cookbook Short stories Atlas Poems Letters
Book spines, vertical-rl
Hours Monday Tuesday Wednesday Thursday Friday
Design32412
Build45364
Review11112
Table headers, sideways-lr

Vertical Text

Beginner

Practical vertical text using writing-mode for table headers, edge labels, and book spines where horizontal text wastes space or does not fit.

Cues light up where there is more to scroll

Your browser can't run this demo

It needs :has(), container queries and scroll-state container queries, which this browser doesn't support yet. It works in Chrome 133+ and Edge 133+. Firefox and Safari don't support it yet.

Needs :has(), container queries and scroll-state container queries

Items

More above More below

  • Build finished
  • New comment on Pricing
  • Invoice paid
  • Deploy to staging
  • Two new sign-ups
  • Backup completed
  • Review requested
  • Password changed
  • Weekly report ready
  • Domain renewed
  • Cache cleared
  • Server restarted

Detect a Scrollable Element

Intermediate

Three CSS techniques for detecting scrollable overflow: scroll-state container queries, a scroll-driven animation flag, and background-attachment scroll shadows.

Thirty flakes in three layers

Falling Snow

Intermediate

Pure CSS snow in three depth layers: each flake falls on one @keyframes rule and sways on another, varied by nth-child cycles.

The same radius, a softer curve

Your browser can't run this demo

It needs corner-shape, which this browser doesn't support yet, so you're seeing a plainer version. It works in Chrome 139+ and Edge 139+. Firefox and Safari don't support it yet.

Needs corner-shape

round
squircle

// this browser has no corner-shape yet, so both tiles are round

Squircle Corners

Beginner

Add corner-shape: squircle to any element with a border-radius and the circular arc becomes a continuous squircle curve.

Press one and its neighbors make room

Squishy Button Group

Intermediate

Pressing one button grows it via flex-grow while the rest shrink to give up space automatically.

Buttons you want to press

Tactile Button

Beginner

Buttons that read as three-dimensional, built from four box-shadow layers that compress on press.

Glass that bends what is behind it

Liquid glass

The stripes bend as they pass behind it.

Liquid Glass Panel

Advanced

A glass panel that bends its backdrop with an SVG displacement filter in Chromium, with a blur fallback and a copy-layer variant.

A glow that travels around the card

Pro plan

A border that never stops moving.

Rotating Glow Border

Intermediate

A spinning gradient ring and glow, driven by an @property-registered angle the browser can tween directly.

One gradient, turning slowly

New this week

two ray layers, turning at different speeds

Rotating Starburst

Intermediate

A slowly rotating starburst drawn from one repeating-conic-gradient, with a clip-path badge and a background burst variant.

Drag the corner handle

An illustrated harbor at dusk with a pink and purple sky, a sun behind mountains, a pier and two sailboats on the water.
The same harbor scene drawn in flat grayscale, before the color edit.
Before After

drag the handle in the bottom right corner

Before and After Slider

Intermediate

A draggable before and after image comparison built with resize and overflow, plus toggle and hover variants.

A bar that inverts what it crosses

DIFFERENCE

// a white bar sweeps across: where it meets the letters, both go black
// overlapping circles subtract each other's color channels

Difference Blend Mode

Advanced

Animated mix-blend-mode: difference: a sweeping bar inverts text while orbiting circles subtract color channels.

A list that reveals as you scroll

↓ scroll to reveal
⚑
Scroll-driven animations
Link animation progress directly to scroll position, with no JavaScript and no IntersectionObserver.
🎨
CSS custom properties
Dynamic theming, animations, and calculations powered entirely by CSS variables.
πŸ“¦
Container queries
Responsive components that adapt to their container's size, not the viewport.
πŸ”—
CSS nesting
Write scoped, composable styles inside each other, using native Sass-style syntax.
πŸ“
Subgrid
Nested grids that align to their parent's tracks, making complex layouts trivial.
✨
@starting-style
Animate elements from their initial state when they first appear in the DOM.

Scroll-Triggered Reveal

Advanced

Elements fade and slide up as they enter the viewport using the CSS scroll-driven animation-timeline: view() property.

Drag the corner to resize

// Files
index.njk
global.css
eleventy.config.js
allExamples.js
base.njk
drag corner β†˜ to resize
// Preview
← select a file to preview

Split Panel

Beginner

Two side by side panels where the left one can be drag resized using CSS resize: horizontal, with no JavaScript.

Four orbits, one star

CSS Geometric Art

Advanced

An animated solar system built entirely with CSS: orbiting planets, a glowing star, no SVG and no JavaScript.

One element, two hundred seventeen shadows

purecss.com

One <div>, and every pixel is a CSS box-shadow value

CSS QR Code

Advanced

A working QR code that scans to purecss.com, drawn with CSS box-shadow on a single element, with no images, no SVG and no JavaScript.

A month in seven columns

May 2026
Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

CSS Calendar

Intermediate

A monthly calendar built with CSS Grid: seven equal columns, hover states, today highlighted, no JavaScript.

Sweep in on entry

↓ scroll to reveal
Design

Typography first.

Great design starts with type. Every layout decision, from spacing to hierarchy to rhythm, flows from the words on the page. CSS gives you full control without a single line of JavaScript.

Performance

No JavaScript overhead.

Scroll-driven animations run on the compositor thread. They don't block the main thread, don't require IntersectionObserver, and can't be slowed by heavy scripts. Pure CSS wins here.

Modern CSS

Native scroll animations.

Scroll-driven animations link movement to scroll position. With progressive enhancement, you can use them today, because non-supporting browsers see the final state.

Scroll Reveal

Advanced

Text sweeps in from the left as it enters the viewport using a scroll-driven clip-path animation, with zero JavaScript.

Two tracks, opposite directions

Pure CSS Zero JavaScript No Dependencies Modern CSS Open Source Built with Eleventy
Scroll Snap CSS Nesting Custom Properties Scroll-Driven Container Queries Cascade Layers

Marquee Text

Beginner

Infinite scrolling text using CSS translateX and @keyframes, the modern replacement for the obsolete <marquee> tag.

Blur, then reveal on hover

Project Nightfall is our internal codename for the upcoming acquisition of Meridian Labs. The deal is expected to close on March 14th for a total of $240 million.

The lead negotiator is Sarah Chen from our legal team. Her direct contact is sarah@example.com . Please keep this confidential until the public release.

// hover to reveal

Redacted Text

Beginner

Sensitive text blurred by default and revealed on hover using CSS filter: blur(), with no JavaScript.

Words rotating on a loop

CSS is
versatile. modern. expressive. fast. versatile.
Build
anything. boldly. natively. beautifully. anything.

Text Ticker

Intermediate

Words rotate vertically in a loop using CSS @keyframes and overflow: hidden, with no JavaScript.

Click a header to expand

CSS nesting lets you write rules inside other rules, like Sass, but natively in the browser. Child selectors, pseudo-classes, and media queries can all live inside their parent block.
When a grid child has min-height: 0 (the default), setting the row track to 0fr collapses it to exactly zero. Transitioning to 1fr lets the browser interpolate to the natural content height, with no JavaScript and no fixed heights.
The max-height approach requires you to set a fixed maximum (like max-height: 1000px), which causes the animation timing to feel wrong for short content, because the browser animates through all the "empty" height before anything collapses. The grid trick avoids this entirely.

Expandable Card

Intermediate

A card that expands to reveal more content on click, with no JavaScript and no max-height hack.

Three rings, drawn on a loop

75%
CSS
60%
JS
88%
HTML

Animated Donut Chart

Advanced

SVG donut chart animated with stroke-dashoffset, with no JavaScript required.

Seven bars, one keyframe

Weekly visitors

65
Mon
45
Tue
80
Wed
55
Thu
90
Fri
70
Sat
30
Sun

CSS Bar Chart

Intermediate

Animated bar chart using CSS custom properties for heights and @keyframes grow animation.

Pie and donut from one gradient

Pie chart

Category A 35%
Category B 25%
Category C 20%
Category D 20%

Donut variant

Revenue 42%
Cost 23%
Tax 20%
Other 15%

CSS Pie Chart

Intermediate

A pie chart drawn with conic-gradient(), with no SVG and no JavaScript.

Hover to fill

Ghost Button Fill Sweep

Beginner

An outlined button that fills with color from left to right on hover using a pseudo-element.

Hover to lift

Magnetic Button

Intermediate

A button with a dramatic lift and shadow on hover using CSS transitions and @starting-style.

Hover to trace the outline

Border Draw Button

Intermediate

A button whose border traces itself on hover using SVG stroke-dashoffset animation.

Three easings side by side

Elastic
bounce
Spring
overshoot
Linear
(for reference)

Elastic Bounce

Intermediate

A ball that bounces with a spring-like overshoot using a custom cubic-bezier easing.

Twenty drops, one keyframe

β˜” CSS Rain

CSS Rain Effect

Intermediate

Animated rain streaks using absolutely-positioned elements and staggered @keyframes.

Twelve particles, one keyframe

Particle Float

Advanced

Floating particles using multiple elements with staggered CSS animation-delay values.

Three blobs, one keyframe

CSS
blob

Morphing Blob Animation

Intermediate

An organic shape that continuously morphs using animated border-radius keyframes.

Scroll inside the box

Your browser can't run this demo

It needs scroll-driven animations, which this browser doesn't support yet. It works in Chrome 115+, Edge 115+, Firefox 159+ and Safari 26+.

Needs scroll-driven animations

Scroll to explore

Each layer moves at a different speed

↑ scroll inside the box ↑

Parallax Scrolling

Advanced

Background and foreground layers move at different speeds using scroll-driven animations.

Thirty-two pieces from five cycles

πŸŽ‰ Congrats!

Confetti Burst

Advanced

CSS confetti animation using transform, @keyframes, and nth-child for staggered timing.

Three lines in sequence

Hello, World! πŸ‘‹

Pure CSS only

// no JavaScript required

Typewriter Effect

Intermediate

Text typed letter by letter using a @keyframes width animation with steps() timing.

Three glowing signs

PURE CSS

NEON GLOW

no javascript

Neon Text Effect

Beginner

Glowing neon text using layered text-shadow values and a flicker CSS animation.

A rail of fixed width cards

Design Systems
12 articles
CSS Tricks
8 articles
Typography
15 articles
Animation
9 articles
Layout
20 articles
Performance
6 articles
Accessibility
11 articles

← scroll or swipe β†’

Scroll Shelf

Beginner

A horizontally scrollable content shelf with scroll-snap for clean stopping points.

Click a thumbnail

Your browser can't run this demo

It needs popover, which this browser doesn't support yet. It works in Chrome 114+, Edge 114+, Firefox 125+ and Safari 17+.

Needs popover

CSS Lightbox

Intermediate

A full-size image overlay with previous and next, using the popover attribute and no JavaScript.

Scroll the rows

Name Role Status Joined
Alice Chen Designer Active Jan 2023
Bob Torres Engineer Active Mar 2023
Carol Kim Manager Pending Jun 2023
David Park Engineer Inactive Aug 2022
Eva MΓΌller Designer Active Nov 2023
Frank Liu Analyst Active Feb 2024
Grace Obi Engineer Pending Apr 2024
Henry Walsh Manager Inactive Sep 2022

Sticky Table Header

Beginner

A table header that stays fixed while scrolling using position: sticky on <thead>.

Two intensities

Glitch
Base
Glitch
Intense

Glitch Effect

Intermediate

An animated glitch effect using CSS clip-path, pseudo-elements, and keyframes, with no JavaScript.

Three fixed ratios

16 / 9
1 / 1
4 / 3

Aspect Ratio Box

Beginner

Maintain a fixed aspect ratio on any element using the aspect-ratio property.

Scroll with the wheel or swipe on touch

Scroll Snap Carousel

Beginner

A horizontal carousel using scroll-snap-type and scroll-snap-align.

Open on click

Open Modal

Modal Dialog

Intermediate

A modal using :target to show/hide without JavaScript.

Gradient filled type

Gradient Text Multi Color Animated Flow

Gradient Text

Beginner

Text filled with a gradient using background-clip:text.

Zoom on hover

Three stacked wave bands in dark gray, teal and lime across the bottom of a black field.
Three concentric rings sitting over a teal and lime radial glow on black.

Image Zoom on Hover

Beginner

Smooth image zoom on hover using CSS transform and overflow:hidden.

Flip on hover

🎨 Front Side
Hover to flip
✨ Back Side
Pure CSS
Card Two
Hover me
No JS needed!

3D Card Flip

Intermediate

A card that flips on hover using CSS 3D transforms and perspective.

Reveal on click

The answer to life, the universe, and everything is 42. All without JavaScript.

Click-to-Reveal

Beginner

Content that reveals on click using a checkbox as state.

Click a heading to expand

What is Pure CSS?
Pure CSS refers to techniques that achieve interactive UI patterns using only CSS, with no JavaScript required.
Which browsers are supported?
All modern browsers support the features used in these examples. Check caniuse.com for specific properties.
Can I use these in production?
Yes! These are real CSS techniques used in production sites. Always consider accessibility requirements for your use case.

Accordion / FAQ

Beginner

Expandable content panels using the <details> and <summary> elements.

Toggle a panel with one click

This content was hidden until you clicked the button, with no JavaScript needed.

Show / Hide Content

Beginner

Toggle visibility of content using a checkbox and the ~ combinator.