From the course: Cutting-Edge CSS

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

Container queries

Container queries - CSS Tutorial

From the course: Cutting-Edge CSS

Container queries

(energetic music) - [Instructor] Media queries are a mainstay of modern web development, but for all their amazingness, they have some severe limitations. Consider this example. We have a component containing two elements, an image and some text. When there is limited horizontal space, the image is displayed at the top of the component and the text below. When there is sufficient horizontal space, the image appears to the left and the text to the right. With old-school media queries, we can create a media query to trigger the layout change of this component at a specific viewport width. In other words, the layout of this component is controlled by the width of the overall viewport, which makes sense if we only ever used a component in one specific location and can design around it. But that's not how components are used. One of the major benefits of a component is it's supposed to be more or less standalone so we can…

Contents