{"id":2981,"date":"2024-07-09T06:59:04","date_gmt":"2024-07-09T12:59:04","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=2981"},"modified":"2024-07-09T06:59:05","modified_gmt":"2024-07-09T12:59:05","slug":"how-to-use-container-queries-now","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/how-to-use-container-queries-now\/","title":{"rendered":"How to use container queries now"},"content":{"rendered":"\n<p>Philip Walton for Google <a href=\"https:\/\/web.dev\/blog\/how-to-use-container-queries-now?hl=en\">responded<\/a> to our question <a href=\"https:\/\/frontendmasters.com\/blog\/weve-got-container-queries-now-but-are-we-actually-using-them\/\">We\u2019ve Got Container Queries Now, But Are We Actually Using Them?<\/a> There are a variety of reasons why usage of them <em>seems<\/em> to be low, but certainly developers worried about browser support is still a factor. The biggest quoted concern is Safari 15, which is entirely reasonable. <\/p>\n\n\n\n<p>Philip lays out a technique where you build a <code>&lt;responsive-container><\/code> Web Component which has a <code>ResizeObserver<\/code> that updates classes on itself you can use for fallback styles in browsers that don&#8217;t support <code>@container<\/code>.<\/p>\n\n\n\n<p>It&#8217;s clever and efficient, but there is stuff I worry about:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>You can&#8217;t just update <code>@media<\/code> queries to <code>@container<\/code> queries with the same numbers, they measure very different things and will now break at different places. <\/li>\n\n\n\n<li>Every component is going to have different breakpoints, and now you need to keep those breakpoints synced in both HTML and CSS. <\/li>\n\n\n\n<li>Dealing with that style duplication is tricky. I would think a lot of setups don&#8217;t have a processing setup that has mixin abilities. <\/li>\n<\/ol>\n\n\n\n<p>Still, if this helps you build a better system you can get to production, godspeed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Philip Walton for Google responded to our question We\u2019ve Got Container Queries Now, But Are We Actually Using Them? There are a variety of reasons why usage of them seems to be low, but certainly developers worried about browser support is still a factor. The biggest quoted concern is Safari 15, which is entirely reasonable. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2330,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29],"tags":[47,7,3,200],"class_list":["post-2981","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-beat","tag-container-queries","tag-css","tag-javascript","tag-resizeobserver"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/05\/pexels-photo-1544944.jpeg?fit=1880%2C1254&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/2981","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=2981"}],"version-history":[{"count":1,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/2981\/revisions"}],"predecessor-version":[{"id":2982,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/2981\/revisions\/2982"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/2330"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=2981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=2981"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=2981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}