This Ancient CSS Feature Is Incredibly Useful

Поділитися
Вставка
  • Опубліковано 1 чер 2024
  • CSS has been around for a long time, but we spend most of our time talking about the new amazing features coming to CSS like container queries, but sometimes the best CSS features are ones that have been there all along. Quantity queries have been a part of CSS for 15 years and they are one of the coolest CSS features that I have never heard of before. In this video I talk all about quantity queries and how you can use them in your projects.
    📚 Materials/References:
    CSS :has Video: • This Is So Much More T...
    CSS :has Article: blog.webdevsimplified.com/202...
    🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    ⏱️ Timestamps:
    00:00 - Introduction
    00:40 - Starting Code
    01:33 - At Least Query
    06:07 - At Most Query
    09:15 - Between Query
    10:50 - Changing Parent Element
    #CSSQuantityQuery #WDS #AdvancedCSS

КОМЕНТАРІ • 48

  • @DMC888
    @DMC888 Місяць тому +3

    I’d write it as (4-n) or (4+n), it just makes more sense to me. You can instantly see which direction you’re going.

  • @EricFressange
    @EricFressange Місяць тому +4

    hi, nice trick to higlight all the childrens of a list.
    The same trick is was used to set equal width on a list items before we had the grid property.
    You can do a little simpler with :has now
    /* At list 4*/
    ul:has( li:nth-child(4)) li {
    background-color: orange;
    }
    /* At most 2*/
    ul:has( li:nth-child(-n + 2):first-child) li {
    background-color:green;
    }
    /* Between 6 and 9 */
    ul:has( li:nth-last-child(n + 6):nth-last-child(-n + 9):first-child) li {
    background-color:purple;
    }

  • @alessandroramelli
    @alessandroramelli Місяць тому +5

    Wow, this is huge!.. I remember a work, where I needed this so badly!! Thank you a lot!! :-)

  • @LV4EVR
    @LV4EVR Місяць тому

    Love this. It'll definitely make it into production.

  • @danielgilleland8611
    @danielgilleland8611 21 день тому

    Wondering what you did in the style to get the list items

  • @aqibmalik6313
    @aqibmalik6313 Місяць тому +1

    KYLE
    i admire ur work so much❤❤❤

  • @deatho0ne587
    @deatho0ne587 Місяць тому +2

    There are still reasons to use this, but I will never do it again
    - Due to most things do not need it at all
    - Even a React, Angular, Vue or basic JS
    - Just add something to the incoming data that adds/removes classes
    - Grid and Flex take care of 99.9% of what I have ever used it for
    - Responsive web design
    Yes, in theory this should be faster/lighter than adding a string of classes to an array but if pulling in API data you semi want to test/modify it anyways.

  • @sicfxmusic
    @sicfxmusic Місяць тому +3

    Right from the CSS Scrolls 📜

  • @bizmarinainfo1808
    @bizmarinainfo1808 Місяць тому

    How would you tie that count in your CSS style to a property coming from the HTML element in this case, the ul element?

  • @clevermissfox
    @clevermissfox Місяць тому +1

    Does this work with nth-of-type as well somehow?
    Idk why but I really struggle with nth-child syntax , I’ll grasp it then it will fall out of my head. I’ve been able to use :nth-child(1 of .item) which is awesome but I just needed a range the other day and had issues finding the right selector. this video would have been perfect then but next time!

  • @avneet12284
    @avneet12284 Місяць тому +1

    So good

  • @bharatdubey83
    @bharatdubey83 Місяць тому

    Sir, can you make a video on building a small project with HTML, CSS and JS and then the same project with React, Redux, Typescript and Tailwind CSS.

  • @AmodeusR
    @AmodeusR Місяць тому +1

    The only situation I see it being useful is in case you want to represent quantity of something, and as it increases it becomes more close the red color to represent fullness. Any other use case?

  • @BurgerBurglar8964
    @BurgerBurglar8964 Місяць тому

    Can you add a ::before text to the boxes so that we can see the colors in words?

  • @toblamabor7072
    @toblamabor7072 Місяць тому

    Hi, please make a video about this great feature of CSS: content-visibility, actually there are 0 tutorials about it

  • @horizondevs
    @horizondevs Місяць тому

    amazing😮

  • @joe-skeen
    @joe-skeen Місяць тому

    There's got to be a way you can define an SCSS construct to make it easier to write rules for between n and m elements...

  • @S-craY
    @S-craY Місяць тому

    Thanks from Russia for this video

  • @JohnBuildWebsites
    @JohnBuildWebsites Місяць тому

    Would it be easier to reason with using `nth-first-child(n -4)`? I think that would do the same, right?

    • @siddiqahmed3274
      @siddiqahmed3274 Місяць тому

      Does first child also take paranthesis?

    • @DMC888
      @DMC888 Місяць тому

      n-4 would start by producing negative values, so it would be different.

  • @NamVu-im2xm
    @NamVu-im2xm Місяць тому +1

    That is really cool but no thank, I'll just use js to calculate the total items. I can't remember those code in the video.

  • @myd1643
    @myd1643 Місяць тому

    damn, i feel old now that you describe it as 'ancient' :P

  • @koksikskkj7937
    @koksikskkj7937 Місяць тому +7

    More easiest solution is to use :has() and :nth-child

    • @KellerG68
      @KellerG68 Місяць тому

      :has() is pretty new and even if the support is really good(92.1%) it's not as good as what he can use here 😉

  • @_MrCode
    @_MrCode Місяць тому +3

    you used word "Ancient" in title, is 😆

  • @user-qj4rr1rm8i
    @user-qj4rr1rm8i Місяць тому

    I can't catch up this mind blowing ancient thing. Sorry Kyle.

  • @strategistaow3520
    @strategistaow3520 Місяць тому

    I didn't learned css i know only styling
    I kind a learned how to use selectors
    But didn't learned why
    And i don't remember selectors

  • @zabi731
    @zabi731 Місяць тому

    Which css framework is the best?

  • @rishiraj2548
    @rishiraj2548 Місяць тому

    🙂👍

  • @Nodsaibot
    @Nodsaibot Місяць тому

    you can do miracles with has() , not(), is() too

  • @bharatchakrabarthy7571
    @bharatchakrabarthy7571 Місяць тому +31

    I feel like from last few months all your video titles are a exaggerated only for them to be explain usual things in web development. I think you can build an audience without clickbaity titles, because your content is really good! no need for this practice

    • @bobwilkinsonguitar6142
      @bobwilkinsonguitar6142 Місяць тому +4

      This is an excellent use. The title is grabby, but still, in conjunction with the thumbnail, shows the general purpose of the video

    • @al-ft1ng
      @al-ft1ng Місяць тому +4

      the title is not clickbait at all.

    • @Hyperion62
      @Hyperion62 Місяць тому +3

      If clickbait tiles weren't effective then people wouldn't use them. I remember an LTT video about their ethical struggles with the effectiveness of clickbait titles vs having informative titles. If you watch them, you have probably noticed which option won.

    • @adambickford8720
      @adambickford8720 Місяць тому +2

      2 types of vids: clickbait and ones you haven't heard of.

    • @burtyful1
      @burtyful1 Місяць тому +2

      Give him a break ... Kyle is one of the best on youtube

  • @fun4stefan
    @fun4stefan Місяць тому +5

    no way im first =)

  • @cherubin7th
    @cherubin7th Місяць тому +4

    CSS has the most dumb gimmicks of all languages ever.