Una broke this down even further<\/a> for us a while back.<\/p>\n","protected":false},"excerpt":{"rendered":"I needed to select some elements between two fixed indexes the other day\u2009\u2014\u2009like literally the second through fifth elements. Ironically, I have a whole post on “Useful :nth-child Recipes” but this wasn’t one of them. The answer, it turns out, isn’t that complicated. But it did twist my brain a little bit.<\/p>\n","protected":false},"author":3,"featured_media":305497,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"I needed to select some elements between two fixed indexes the other day\u2009\u2014\u2009like literally the second through fifth elements. Not complicated, but definitely a brain twister.","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[4],"tags":[867,1383],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2020\/03\/nth-selector.png?fit=1200%2C600&ssl=1","jetpack-related-posts":[{"id":305459,"url":"https:\/\/css-tricks.com\/css-nth-of-class-selector\/","url_meta":{"origin":342736,"position":0},"title":"CSS :nth-of-class selector","date":"March 23, 2020","format":false,"excerpt":"That's not a thing. But it kinda is! Bram covers how frustrating .bar:nth-child(2) is. It's not \"select the second element of class .bar.\" It's \"select the second element if it also has the class .bar.\" The good news? There is a real selector that does the former: :nth-child(2 of .bar)\u2026","rel":"","context":"In "Link"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2020\/03\/nth-selector.png?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":193009,"url":"https:\/\/css-tricks.com\/abusing-css3s-nth-child-selector-invent-new-ones\/","url_meta":{"origin":342736,"position":1},"title":"Abusing CSS3’s nth-child selector to invent new ones","date":"January 12, 2015","format":false,"excerpt":"Matt Mastracci on combining existing positional selectors in interesting ways to create logic you might not have thought possible. For instance, select all elements only if there are five of them, with: span:first-child:nth-last-child(5), span:first-child:nth-last-child(5) ~ span { \/* select the span if its BOTH first and 5th from the end,\u2026","rel":"","context":"In "Link"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":334958,"url":"https:\/\/css-tricks.com\/how-to-map-mouse-position-in-css\/","url_meta":{"origin":342736,"position":2},"title":"How to Map Mouse Position in CSS","date":"March 1, 2021","format":false,"excerpt":"Let\u2019s look at how to get the user\u2019s mouse position and map it into CSS custom properties: --positionX and --positionY. We could do this in JavaScript. If we did, we could do things like make make an element draggable or move a background. But actually, we can still do similar\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2021\/02\/css-mouse-cursor-mapping.gif?fit=900%2C450&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":367178,"url":"https:\/\/css-tricks.com\/exploring-css-grids-implicit-grid-and-auto-placement-powers\/","url_meta":{"origin":342736,"position":3},"title":"Exploring CSS Grid\u2019s Implicit Grid and Auto-Placement Powers","date":"August 1, 2022","format":false,"excerpt":"When working with CSS Grid, the first thing to do is to set display: grid on the element that we want to be become a grid container. Then we explicitly define the grid using a combination of grid-template-columns, grid-template-rows, and grid-template-areas. And from there, the next step is to place\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2022\/07\/s_F4C924AEFDB642C9861B01422787157264225531682D164A8C42B48A83B84E89_1656674978920_image.png?fit=608%2C742&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":9657,"url":"https:\/\/css-tricks.com\/useful-nth-child-recipies\/","url_meta":{"origin":342736,"position":4},"title":"Useful :nth-child Recipes","date":"June 16, 2011","format":false,"excerpt":"I get a little giddy when I come across perfect uses for :nth-child or :nth-of-type (read about the difference). The better you understand them, the more css nerdgasms you get to have!","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":354115,"url":"https:\/\/css-tricks.com\/supports-selector\/","url_meta":{"origin":342736,"position":5},"title":"@supports selector()","date":"October 19, 2021","format":false,"excerpt":"I didn't realize the support for @supports determining selector support was so good! I usually think of @supports as a way to test for property: value pair support. But with the selector() function, we can test for selector support as well. It looks like this: @supports selector(:nth-child(1 of .foo)) {\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2019\/02\/supports-code.png?fit=1200%2C600&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/342736"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=342736"}],"version-history":[{"count":5,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/342736\/revisions"}],"predecessor-version":[{"id":343278,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/342736\/revisions\/343278"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/305497"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=342736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=342736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=342736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}