This Ancient CSS Feature Is Incredibly Useful

Поделиться
HTML-код
  • Опубликовано: 14 июн 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.

  • @alessandroramelli
    @alessandroramelli 2 месяца назад +5

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

  • @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;
    }

  • @LV4EVR
    @LV4EVR Месяц назад

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

  • @aqibmalik6313
    @aqibmalik6313 2 месяца назад +1

    KYLE
    i admire ur work so much❤❤❤

  • @danielgilleland8611
    @danielgilleland8611 Месяц назад

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

  • @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 📜

  • @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!

  • @bizmarinainfo1808
    @bizmarinainfo1808 2 месяца назад

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

  • @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?

  • @avneet12284
    @avneet12284 2 месяца назад +1

    So good

  • @horizondevs
    @horizondevs Месяц назад

    amazing😮

  • @toblamabor7072
    @toblamabor7072 Месяц назад

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

  • @BurgerBurglar8964
    @BurgerBurglar8964 2 месяца назад

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

  • @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...

  • @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.

  • @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.

  • @S-craY
    @S-craY Месяц назад

    Thanks from Russia for this video

  • @NamVu-im2xm
    @NamVu-im2xm 2 месяца назад +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

  • @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

  • @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 2 месяца назад +3

    you used word "Ancient" in title, is 😆

  • @user-qj4rr1rm8i
    @user-qj4rr1rm8i Месяц назад

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

  • @rishiraj2548
    @rishiraj2548 2 месяца назад

    🙂👍

  • @zabi731
    @zabi731 Месяц назад

    Which css framework is the best?

  • @fun4stefan
    @fun4stefan 2 месяца назад +5

    no way im first =)

  • @Nodsaibot
    @Nodsaibot Месяц назад

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

  • @bharatchakrabarthy7571
    @bharatchakrabarthy7571 2 месяца назад +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 2 месяца назад +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 2 месяца назад +4

      the title is not clickbait at all.

    • @Hyperion62
      @Hyperion62 2 месяца назад +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

  • @cherubin7th
    @cherubin7th 2 месяца назад +4

    CSS has the most dumb gimmicks of all languages ever.