{"id":28934,"date":"2019-09-18T23:11:22","date_gmt":"2019-09-18T15:11:22","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=28934"},"modified":"2019-09-22T23:24:17","modified_gmt":"2019-09-22T15:24:17","slug":"quantity-queries-css-quantity-aware","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/","title":{"rendered":"Use Quantity Queries to Make Your CSS Quantity-Aware"},"content":{"rendered":"<p><strong>Quantity queries<\/strong> are <strong>specially set-up CSS selectors<\/strong> that allow developers to <strong>make their code quantity-aware<\/strong>. In responsive design, we usually use media queries to adapt our design to different viewports. In some cases however, we may want to switch to a different layout or use other dimensions or aesthetics <strong>after a certain quantity of the same content type is present<\/strong> on the screen.<\/p>\n<p class=\"recommended_top\">\n\t\t\t\t\t<strong>Read Also:<\/strong>\u00a0\n\t\t\t\t\t<a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/css-priority-level\/\">A Guide to Understanding CSS Style Priorities<\/a>\n\t\t\t\t<\/p>\n<p>It\u2019s a frequent issue with dynamic websites that we don\u2019t always know in advance <strong>how many items will be on the screen<\/strong>. Think about tags at the end of blog posts, <a href=\"https:\/\/www.hongkiat.com\/blog\/ux-tips-optimize-filtered-navigation\/\">product-specific filters<\/a> in the navigation of eCommerce sites, or  on-site search results. This is when <strong>quantity queries<\/strong> can give us an elegant, CSS-only solution, and save us from the hassle of using JavaScript.<\/p>\n<h2>How quantity queries are composed<\/h2>\n<p>We can build <strong>three kinds of quantity queries<\/strong>:<\/p>\n<ol>\n<li><strong>\"At-least\" queries<\/strong> when there are <strong>more than<\/strong> a certain quantity of the same content type on the screen.<\/li>\n<li><strong>\"At-most\" queries<\/strong> when there are <strong>less than<\/strong> a certain quantity of the same content type on the screen.<\/li>\n<li><strong>\"Between\" queries<\/strong> when there are <strong>more than<\/strong> a certain quantity, but <strong>less than<\/strong> another quantity of the same content type on the screen.<\/li>\n<\/ol>\n<p>All three types of quantity queries are built by using the <strong><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/:nth-last-child\" target=\"_blank\" rel=\"noopener noreferrer\"><code>:nth-last-child<\/code><\/a> CSS pseudo-class<\/strong> and the <strong><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/General_sibling_selectors\" target=\"_blank\" rel=\"noopener noreferrer\">general sibling selector<\/a> (<code>~<\/code>)<\/strong>, while \"at-most\" and \"between\" queries also make use of the <strong><a href=\"https:\/\/developer.mozilla.org\/en\/docs\/Web\/CSS\/:first-child\" target=\"_blank\" rel=\"noopener noreferrer\"><code>:first-child<\/code><\/a> pseudo-class<\/strong>.<\/p>\n<p>The <code>:nth-last-child<\/code> pseudo-class behaves similarly to <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/:nth-child\" target=\"_blank\" rel=\"noopener noreferrer\"><code>:nth-child<\/code><\/a>, however it <strong>starts the counting from the last child<\/strong>, while the general sibling selector (<code>~<\/code>) <strong>selects all elements that come after a certain sibling element<\/strong>.<\/p>\n<p class=\"note\"> <strong>Recommended Reading:<\/strong> <a href=\"https:\/\/www.hongkiat.com\/blog\/css3-pseudo-classes\/\">Web Design: A Guide to CSS3 pseudo-classes<\/a><\/p>\n<h2>\"At-least\" queries<\/h2>\n<p>The most important thing to understand is that quantity queries select <strong>all elements<\/strong> that belong to the same parent element, as the goal is to <strong>assign the same design<\/strong> to all the elements that <strong>meet the quantity criteria<\/strong>.<\/p>\n<p>In the code snippet below, we select all <code>&lt;li&gt;<\/code> elements in an unordered list that <strong>contains minimum five list elements<\/strong>.<\/p>\n<pre>\r\n\/* \"At-least\" query *\/\r\nul li:nth-last-child(n+5),\r\nul li:nth-last-child(n+5) ~ li {\r\n  background-color: orange;\r\n}\r\n<\/pre>\n<p>As you can see, an \"at-least\" query is <strong>made up of two CSS selectors<\/strong>. The first selector, <code>ul li:nth-last-child(n+5)<\/code> selects all <code>&lt;li&gt;<\/code> elements that are <strong>at least five elements far from the last child<\/strong>. This style rule alone is not enough though, as it doesn\u2019t make all the elements look the same\u2014the last four elements will keep their original style. That\u2019s why we need to add the second selector, that selects <strong>all general siblings<\/strong> of the previously selected elements.<\/p>\n<p>To get back to our example code, it adds an orange background to all the elements of unordered lists that <strong>have at least five elements<\/strong>, while unordered lists with less than five <code>&lt;li&gt;<\/code> elements will <strong>keep their default (blue) color<\/strong>. You can <strong>test live<\/strong> how the \"at-least\" query works in the Codepen pen below.<\/p>\n<p><iframe height=\"514\" scrolling=\"no\" title=\"At-least quantity queries\" src=\"https:\/\/codepen.io\/hkdc\/embed\/Ypvmrq\/?height=514&theme-id=0&default-tab=result&embed-version=2\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" style=\"width: 100%;\">See the Pen <a href=\"https:\/\/codepen.io\/hkdc\/pen\/Ypvmrq\/\" rel=\"nofollow\">\u201cAt-least\u201d quantity queries<\/a> by HONGKIAT (<a href=\"https:\/\/codepen.io\/\/hkdc\" rel=\"nofollow\">@hkdc<\/a>) on <a href=\"https:\/\/codepen.io\/\" rel=\"nofollow\">CodePen<\/a>. <\/iframe><\/p>\n<h2>\"At-most\" queries<\/h2>\n<p>\"At-most\" queries are also <strong>made up of two selectors<\/strong>, however they don\u2019t only rely on the <code>:nth-last-child<\/code> pseudo-class, but also on <code>:first-child<\/code>. The example code below selects all <code>&lt;li&gt;<\/code> elements that belong to an unordered list that have <strong>maximum five list elements<\/strong>.<\/p>\n<pre>\r\n\/* \"At-most\" query *\/\r\nul li:nth-last-child(-n+5):first-child,\r\nul li:nth-last-child(-n+5):first-child ~ li {\r\n  background-color: orange;\r\n}\r\n<\/pre>\n<p>The first part of the first selector, <code>:nth-last-child(-n+5)<\/code>, uses a <strong>negative value<\/strong> that <strong>swaps the direction of the selection<\/strong>\u2014it still counts from the last child (which is the built-in nature of the <code>:nth-last-child<\/code> pseudo-class), however now it will <strong>select the last five elements<\/strong> (i.e. the elements that are <strong>not<\/strong> at least five elements far from the last child). This selector selects the last five elements of any unordered list, however we only want to select those <strong>that have maximum five elements<\/strong> (as this way all the elements will be selected).<\/p>\n<p>That\u2019s why we need to combine it with the <code>:first-child<\/code> pseudo-class that will select the first elements of the previously selected list elements, but only for those that are <strong>also the first child of their <code>&lt;ul&gt;<\/code> parent<\/strong>, which is only true for unordered lists that contain maximum five <code>&lt;li&gt;<\/code> elements.<\/p>\n<p>Now we don\u2019t have to do anything than to <strong>add the second selector<\/strong>, which will <strong>select the general siblings<\/strong> of the previously selected <code>:first-child<\/code> elements. And that\u2019s it, our \"at-most\" query is done. Y  ou can play around with the CSS code in the live demo below to see how it works.<\/p>\n<p><iframe height=\"518\" scrolling=\"no\" title=\"At-most quantity queries\" src=\"https:\/\/codepen.io\/hkdc\/embed\/dOKxqM\/?height=518&theme-id=0&default-tab=result&embed-version=2\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" style=\"width: 100%;\">See the Pen <a href=\"https:\/\/codepen.io\/hkdc\/pen\/dOKxqM\/\" rel=\"nofollow\">\u201cAt-most\u201d quantity queries<\/a> by HONGKIAT (<a href=\"https:\/\/codepen.io\/\/hkdc\" rel=\"nofollow\">@hkdc<\/a>) on <a href=\"https:\/\/codepen.io\/\" rel=\"nofollow\">CodePen<\/a>. <\/iframe><\/p>\n<h2>\"Between\" queries<\/h2>\n<p>The \"between\" query combines the code we\u2019ve used for the \"at-least\" and \"at-most\" queries. The code example below selects all elements of unordered lists that <strong>contain minimum five but maximum six list elements<\/strong>.<\/p>\n<pre>\r\n\/* \"Between\" query *\/\r\nul li:nth-last-child(n+5):nth-last-child(-n+6):first-child,\r\nul li:nth-last-child(n+5):nth-last-child(-n+6):first-child ~ li {\r\n  background-color: orange;\r\n}\r\n<\/pre>\n<p>To build a \"between query\" we <strong>concatenate the CSS selectors<\/strong> belonging to the appropriate \"at-least\" and \"at-most\" queries. The \"at-least\" query in our example is <code>:nth-last-child(n+5)<\/code>, while the \"at-most\" query is <code>:nth-last-child(-n+6):first-child<\/code>, we simply <strong>join them with a colon<\/strong>.<\/p>\n<p><iframe height=\"603\" scrolling=\"no\" title=\"Between quantity queries\" src=\"https:\/\/codepen.io\/hkdc\/embed\/GNBKpy\/?height=603&theme-id=0&default-tab=result&embed-version=2\" frameborder=\"no\" allowtransparency=\"true\" allowfullscreen=\"true\" style=\"width: 100%;\">See the Pen <a href=\"https:\/\/codepen.io\/hkdc\/pen\/GNBKpy\/\" rel=\"nofollow\">\u201cBetween\u201d quantity queries<\/a> by HONGKIAT (<a href=\"https:\/\/codepen.io\/\/hkdc\" rel=\"nofollow\">@hkdc<\/a>) on <a href=\"https:\/\/codepen.io\/\" rel=\"nofollow\">CodePen<\/a>. <\/iframe><\/p>\n<h2>Use cases<\/h2>\n<p>Quantity queries have many <strong>interesting use cases<\/strong> from content-aware navigations to automatic grid systems, here\u2019s a collection of some of the best:<\/p>\n<ul>\n<li>A List Apart: <a href=\"https:\/\/alistapart.com\/article\/quantity-queries-for-css\" target=\"_blank\" rel=\"noopener noreferrer\">How to build a content-aware navigation<\/a><\/li>\n<li>Tomango: <a href=\"https:\/\/www.tomango.co.uk\/blog\/\" target=\"_blank\" rel=\"noopener noreferrer\">A tag list and a flexible grid system<\/a><\/li>\n<li>Charlotte Jackson\u2019s blog: <a href=\"https:\/\/www.the215guys.com\/learning\/quantity-queries-and-flexbox\/\" target=\"_blank\" rel=\"noopener noreferrer\">Code experiments with quantity queries<\/a><\/li>\n<li>Codepen: <a href=\"https:\/\/codepen.io\/\/onediv\/pen\/GgEKMR\/\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">An automatic grid system by Vincent Durand<\/a><\/li>\n<li>Codepen: <a href=\"https:\/\/codepen.io\/\/luclemo\/pen\/VvROXO\/\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">An image grid using quantity queries and Flexbox by Lucas Lemonnier<\/a><\/li>\n<li>Codepen: <a href=\"https:\/\/codepen.io\/\/pixelthing\/pen\/OyrWgo\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">A collapsable link list by Craig Morey<\/a><\/li>\n<\/ul>\n<h2>Tools to build quantity queries<\/h2>\n<p>There are some great <strong>developer tools<\/strong> out there that can help you <strong>build quantity queries<\/strong> more easily.<\/p>\n<h3><a href=\"https:\/\/quantityqueries.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Quantity query builder<\/a><\/h3>\n<p>This handy <strong><a href=\"https:\/\/quantityqueries.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">quantity query builder<\/a><\/strong> makes the creation of quantity queries easy and straightforward. You only have to <strong>fill in three input fields<\/strong> (elements to be counted, type of query, amount of items), and the tool <strong>generates the quantity query<\/strong> you need.<\/p>\n<figure><a href=\"https:\/\/quantityqueries.com\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/quantity-queries-css-quantity-aware\/quantity-query-builder.jpg\" width=\"800\" height=\"449\" alt=\"Quantity query builder\"><\/a><\/figure>\n<h3><a href=\"https:\/\/github.com\/danielguillan\/quantity-queries\" target=\"_blank\" rel=\"noopener noreferrer\">Quantity query mixins for SASS<\/a><\/h3>\n<p>You can use these simple <a href=\"https:\/\/github.com\/danielguillan\/quantity-queries\" target=\"_blank\" rel=\"noopener noreferrer\">quantity query mixins<\/a> <strong>in your Sass projects<\/strong>. The author, Daniel Guillan, also created a <a href=\"https:\/\/codepen.io\/\/danielguillan\/pen\/GgBOxm\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">Codepen demo<\/a> where you can check out the mixins in action.<\/p>\n<figure><a href=\"https:\/\/github.com\/danielguillan\/quantity-queries\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/quantity-queries-css-quantity-aware\/qq-mixins.jpg\" width=\"800\" height=\"423\" alt=\"Quantity query mixins\"><\/a><\/figure>\n<h3><a href=\"https:\/\/github.com\/pascalduez\/postcss-quantity-queries\" target=\"_blank\" rel=\"noopener noreferrer\">PostCSS plugin for quantity queries<\/a><\/h3>\n<p>This <strong><a href=\"https:\/\/github.com\/pascalduez\/postcss-quantity-queries\" target=\"_blank\" rel=\"noopener noreferrer\">PostCSS plugin<\/a><\/strong> is built on top of the aforementioned quantity query mixins, and allows you to include quantity queries <strong>into your PostCSS workflow<\/strong>.<\/p>\n<figure><a href=\"https:\/\/github.com\/pascalduez\/postcss-quantity-queries\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/quantity-queries-css-quantity-aware\/qq-postcss.jpg\" width=\"800\" height=\"494\" alt=\"PostCSS plugin for quantity queries\"><\/a><\/figure>\n<p class=\"recommended_top\">\n\t\t\t\t\t<strong>Read Also:<\/strong>\u00a0\n\t\t\t\t\t<a target=\"_blank\" href=\"https:\/\/www.hongkiat.com\/blog\/20-useful-css-tips-for-beginners\/\">20 Basic CSS Tips for Designers<\/a>\n\t\t\t\t<\/p>","protected":false},"excerpt":{"rendered":"<p>Quantity queries are specially set-up CSS selectors that allow developers to make their code quantity-aware. In responsive design, we usually use media queries to adapt our design to different viewports. In some cases however, we may want to switch to a different layout or use other dimensions or aesthetics after a certain quantity of the&hellip;<\/p>\n","protected":false},"author":146,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[3392],"tags":[507,4501],"topic":[4520],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Use Quantity Queries to Make Your CSS Quantity-Aware - Hongkiat<\/title>\n<meta name=\"description\" content=\"Quantity queries are specially set-up CSS selectors that allow developers to make their code quantity-aware. In responsive design, we usually use media\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Use Quantity Queries to Make Your CSS Quantity-Aware\" \/>\n<meta property=\"og:description\" content=\"Quantity queries are specially set-up CSS selectors that allow developers to make their code quantity-aware. In responsive design, we usually use media\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-18T15:11:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-09-22T15:24:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/quantity-queries-css-quantity-aware\/quantity-query-builder.jpg\" \/>\n<meta name=\"author\" content=\"Anna Monus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Anna Monus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/\"},\"author\":{\"name\":\"Anna Monus\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/a601053a0ab457901e00cdc83bd5359e\"},\"headline\":\"Use Quantity Queries to Make Your CSS Quantity-Aware\",\"datePublished\":\"2019-09-18T15:11:22+00:00\",\"dateModified\":\"2019-09-22T15:24:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/\"},\"wordCount\":1065,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/quantity-queries-css-quantity-aware\\\/quantity-query-builder.jpg\",\"keywords\":[\"CSS\",\"CSS Tutorials\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/\",\"name\":\"Use Quantity Queries to Make Your CSS Quantity-Aware - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/quantity-queries-css-quantity-aware\\\/quantity-query-builder.jpg\",\"datePublished\":\"2019-09-18T15:11:22+00:00\",\"dateModified\":\"2019-09-22T15:24:17+00:00\",\"description\":\"Quantity queries are specially set-up CSS selectors that allow developers to make their code quantity-aware. In responsive design, we usually use media\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/quantity-queries-css-quantity-aware\\\/quantity-query-builder.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/quantity-queries-css-quantity-aware\\\/quantity-query-builder.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/quantity-queries-css-quantity-aware\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Use Quantity Queries to Make Your CSS Quantity-Aware\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/a601053a0ab457901e00cdc83bd5359e\",\"name\":\"Anna Monus\",\"description\":\"Anna is Technical Editor and Writer for Hongkiat.com. She mainly covers front-end frameworks, web standards, accessibility, WordPress development, and UX design.\",\"sameAs\":[\"https:\\\/\\\/www.annalytic.com\\\/\"],\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/anna_monus\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Use Quantity Queries to Make Your CSS Quantity-Aware - Hongkiat","description":"Quantity queries are specially set-up CSS selectors that allow developers to make their code quantity-aware. In responsive design, we usually use media","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/","og_locale":"en_US","og_type":"article","og_title":"Use Quantity Queries to Make Your CSS Quantity-Aware","og_description":"Quantity queries are specially set-up CSS selectors that allow developers to make their code quantity-aware. In responsive design, we usually use media","og_url":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2019-09-18T15:11:22+00:00","article_modified_time":"2019-09-22T15:24:17+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/quantity-queries-css-quantity-aware\/quantity-query-builder.jpg","type":"","width":"","height":""}],"author":"Anna Monus","twitter_card":"summary_large_image","twitter_creator":"@hongkiat","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Anna Monus","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/"},"author":{"name":"Anna Monus","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/a601053a0ab457901e00cdc83bd5359e"},"headline":"Use Quantity Queries to Make Your CSS Quantity-Aware","datePublished":"2019-09-18T15:11:22+00:00","dateModified":"2019-09-22T15:24:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/"},"wordCount":1065,"commentCount":3,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/quantity-queries-css-quantity-aware\/quantity-query-builder.jpg","keywords":["CSS","CSS Tutorials"],"articleSection":["Coding"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/","url":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/","name":"Use Quantity Queries to Make Your CSS Quantity-Aware - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/quantity-queries-css-quantity-aware\/quantity-query-builder.jpg","datePublished":"2019-09-18T15:11:22+00:00","dateModified":"2019-09-22T15:24:17+00:00","description":"Quantity queries are specially set-up CSS selectors that allow developers to make their code quantity-aware. In responsive design, we usually use media","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/quantity-queries-css-quantity-aware\/quantity-query-builder.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/quantity-queries-css-quantity-aware\/quantity-query-builder.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/quantity-queries-css-quantity-aware\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Use Quantity Queries to Make Your CSS Quantity-Aware"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/a601053a0ab457901e00cdc83bd5359e","name":"Anna Monus","description":"Anna is Technical Editor and Writer for Hongkiat.com. She mainly covers front-end frameworks, web standards, accessibility, WordPress development, and UX design.","sameAs":["https:\/\/www.annalytic.com\/"],"url":"https:\/\/www.hongkiat.com\/blog\/author\/anna_monus\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-7wG","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/28934","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/146"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=28934"}],"version-history":[{"count":4,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/28934\/revisions"}],"predecessor-version":[{"id":48772,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/28934\/revisions\/48772"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=28934"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=28934"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=28934"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=28934"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}