{"id":357080,"date":"2021-11-22T07:29:03","date_gmt":"2021-11-22T15:29:03","guid":{"rendered":"https:\/\/css-tricks.com\/?p=357080"},"modified":"2023-07-06T14:22:29","modified_gmt":"2023-07-06T21:22:29","slug":"responsive-layouts-fewer-media-queries","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/responsive-layouts-fewer-media-queries\/","title":{"rendered":"Responsive Layouts, Fewer Media Queries"},"content":{"rendered":"\n

We cannot talk about web development without talking about Responsive Design. It\u2019s just a given these days and has been for many years. Media queries<\/a> are a part of Responsive Design and they aren\u2019t going anywhere. Since the introduction of media queries (literally decades ago), CSS has evolved to the points that there are a lot of tricks that can help us drastically reduce the usage of media queries we use. In some cases, I will show you how to replace multiple media queries with only one CSS declaration. These approaches can result in less code, be easier to maintain, and be more tied to the content at hand.<\/p>\n\n\n\n\n\n\n\n

Let\u2019s first take a look at some widely used methods to build responsive layouts without media queries. No surprises here \u2014 these methods are related to flexbox<\/a> and grid<\/a>.<\/p>\n\n\n

Using flex<\/code> and flex-wrap<\/code><\/h3>\n\n\n
\n