8 CSS Container Queries
Dive into the new paradigm of component-driven styling using native CSS Container Queries. This collection demonstrates how elements can finally respond to the size of their parent container, not just the viewport, solving the core challenge of responsive component design. This technique achieves true component independence by allowing a single component block to adapt its layout regardless of where it’s placed in the page structure.
Last updated:
Tailwind Fluid Grid
An impressive, “living” gallery where the active image smoothly expands, pushing neighbors aside, while inactive elements elegantly dim and desaturate, focusing attention on the content.
Open Props Bento Grid
A modern, visually appealing content grid that smoothly assembles on scroll, adapting seamlessly to any screen size.
CSS List Filtering with :has()
A comprehensive demonstration of CSS :has() selector and Container Queries capabilities. :has() is used to toggle between light/dark themes and to dynamically filter cards by category without using JavaScript.
Container Query Bookstore
Integration of Drag and Drop functionality using Dragula.js and Web Components. The Dragula script handles the drop event, dynamically changing the background color of the stage container via a CSS variable taken from the dragged element.
Scroll-Snap Grid Navigation with Intersection Observer
See how the Intersection Observer powers the 2D grid navigation: the Scroll Snap logic handles mandatory cell binding, while a JS utility adds support for keyboard arrow navigation and responsive typography using cqi/dvh units.
Responsive Speech Bubbles using CSS Container Queries
A stylish, pure CSS solution for creating speech bubbles with custom tails using the :after pseudo-element and the advanced clip-path: polygon() property to give the content frame a unique, angled edge shape.
Pure CSS Responsive Hex Grid
An adaptive hexagonal grid without media queries, built on Container Queries, where the column count and the position of each element are calculated in CSS via complex calc() functions. The code demonstrates progressive enhancement - with a fallback to @property and a tan(atan2()) math trick to emulate division in older browsers.
CSS @container scroll-state() Faux PiP Video
A demonstration of the current use of @container style() and scroll-state() to create context-aware UI. The key feature: the video element’s styles and animations are entirely determined not by the viewport, but by the element’s position within its parent container.