Code '23

CSS Container Queries: Reshaping the Way We Approach Responsive Web Design

About this presentation

The rise of component-based architecture has brought new challenges to web developers, including the need for more granular control over layouts within individual components. While media queries have been a cornerstone of responsive web design for over a decade, they fall short when it comes to solving layout issues at the component level. Enter CSS container queries, a new tool that allows developers to style components based on their available space within a containing element. With container queries, we can use the same component everywhere, but it's restyling itself to fit best within the UI where it lives. In this talk, we will explore the capabilities of container queries and how they can be used to achieve complex layouts without the need for heavy scripting or ResizeObserver hacks. We will cover the different container types, including inline-size and size, and showcase real-world examples of container queries in action with flexbox and grid.