// 37 examples

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.

What is Pure CSS?
Techniques that work without any JavaScript.
Does it work everywhere?
Modern browsers support all examples here.
Layout Beginner
Accordion / FAQ
Expandable content panels using the <details> and <summary> elements.
Layout Beginner
Scroll Snap Carousel
A horizontal carousel using scroll-snap-type and scroll-snap-align.
Name Role Status
Alice Chen Designer Active
Bob Torres Engineer Pending
Carol Kim Manager Active
David Park Analyst Inactive
Layout Beginner
Sticky Table Header
A table header that stays fixed while scrolling using position: sticky on <thead>.
What is CSS nesting? +
CSS nesting lets you write rules inside other rules, natively in the browser.
How does grid-template-rows work? +
Layout Intermediate
Expandable Card
A card that expands to reveal more content on click, with no JavaScript and no max-height hack.
Project Nightfall is our codename for the acquisition of Meridian Labs. The deal closes on March 14th for $240M.
// hover to reveal
Layout Beginner
Redacted Text
Sensitive text blurred by default and revealed on hover using CSS filter: blur(), with no JavaScript.
Pure CSS Zero JS Modern CSS Pure CSS Zero JS Modern CSS
CSS Nesting Container Q Scroll-Driven CSS Nesting Container Q Scroll-Driven
Layout Beginner
Marquee Text
Infinite scrolling text using CSS translateX and @keyframes, the modern replacement for the obsolete <marquee> tag.
Scroll-driven animations
No JavaScript required.
🎨
CSS custom properties
Dynamic theming in CSS.
📦
Container queries
Component-scoped layouts.
Layout Advanced
Scroll-Triggered Reveal
Elements fade and slide up as they enter the viewport using the CSS scroll-driven animation-timeline: view() property.