nth-child() just got an upgrade

Поделиться
HTML-код
  • Опубликовано: 4 фев 2025

Комментарии • 100

  • @BaileyPoint
    @BaileyPoint Год назад +2

    This is awesome! I just commented on one of your other videos saying we needed something like this (though I would have expected an "nth-of-selector" syntax)!

  • @rafasharla
    @rafasharla Год назад +4

    Hey Kevin! It's just really inspiring to see how excited you get with the new things that are coming up. Makes me want to dive really deep on CSS. Thank you for sharing your excitement :)

    • @KevinPowell
      @KevinPowell  Год назад +2

      Glad my enthusiam manages to make it's way through!

  • @MRVDOG
    @MRVDOG Год назад +4

    I actually needed to do this today, and realised I couldn't, but this is exciting!!! can't wait for full support

    • @futurefox128
      @futurefox128 Год назад

      Make sure to check out Zoe Pentaleri's post (somewhere at the top as of now) for a 100% supported solution for 1st child selection.
      (yea I could have just copypasted it here, but I didn't want to make it seem like I'm stealing their answer... which is exactly what that would have ment ^^)

  • @philippciftci6649
    @philippciftci6649 Год назад

    I want to make a Knowlegde Meeting in my office soon about some cool CSS and HTML features.I follow your channel already a long time and I'm a huge fan. Now I'm going again through most of your videos to make a list of the coolest ones and going to shine like a star. 😂

  • @KeithGrant
    @KeithGrant Год назад

    I don't know how I missed this in the Chrome release notes, but thanks for pointing it out!

  • @Lucsy3012
    @Lucsy3012 Год назад

    Great to see this working now! I was always frustrated with nth-of-type and how it worked

  • @goodshiro10
    @goodshiro10 Год назад +1

    Wait, things all I needed in the past are new videos of yours 😶😶Also thanks for sharing it 🙂

  • @solvedfyi
    @solvedfyi Год назад

    Video title good, length good, point good, you got it

  • @adamuk73
    @adamuk73 Год назад

    This question gets asked so often on stack overflow. I'm glad it's getting fixed now

  • @eioluseyi
    @eioluseyi Год назад +62

    Hi Kevin, how do you stay on top of the css updates?

    • @rato_gordo
      @rato_gordo Год назад +1

      Curious too.

    • @sallybugs1695
      @sallybugs1695 Год назад +2

      Google

    • @turolretar
      @turolretar Год назад +4

      MDN probably, maybe browser engines blogs

    • @eioluseyi
      @eioluseyi Год назад +4

      @@turolretar yeah, I use those too. I'm just really curious about how Kevin handles it for himself also.
      I'm secretly hoping for a video on this 🥺

    • @AndersFloor
      @AndersFloor Год назад +8

      He follows Kevin Powell on RUclips ;)

  • @TheRalic
    @TheRalic Год назад

    How did I skip this video? 😮
    Thank you for explaining this!

  • @AlvinIsChipmunk
    @AlvinIsChipmunk Год назад +18

    Awesome video as always Kevin. Just a question though, how do you keep yourself updated with all these upgrades? Is there a newsletter for that?

    • @KevinPowell
      @KevinPowell  Год назад +10

      I keep up with the new features coming to the beta of browsers, since that means it'll be going to production soon enough, and all the browsers post blog updates with all the new features that are included. I also follow a bunch of dev rel people on Twitter who work at the browsers who always are sharing stuff about what's on the way. csslayout.news/ by Rachel Andrew is great as well.

  • @Issvor
    @Issvor Год назад +1

    I love that final comment you said.
    "Even if somebody is on an older device that can't update the browser, it's not the end of the world. they still have a working experience, even if it's not a perfect one".

  • @christophermatt5925
    @christophermatt5925 Год назад

    Thank you Master Powell 😁

  • @Pesthuf
    @Pesthuf Год назад

    Holy crap. I've been wanting this for so long.

  • @DurgeshMaheshwaritela
    @DurgeshMaheshwaritela Год назад

    It's going to help a lot, Thanks

  • @zoepentaleri
    @zoepentaleri Год назад +9

    Just an FYI to people who might want to replicate the effect in the video, you can achieve it without the new syntax too.
    article > .clr-accent { /* highlighted style */ }
    article > .clr-accent ~ .clr-accent { /* normal style */ }
    This first selects all elements of .clr-accent, then only selects the elements of .clr-accent that follow another .clr-accent - i.e. all but the first one.

    • @futurefox128
      @futurefox128 Год назад

      This comment should get pinned. Same effect for 1st element and full browser support.
      I think the same effect can be achieved by using :not() and this has the benefit of not having to reapply the wanted properties of "normal style" to "highlighted style":
      .class { /*normal style*/ }
      parent > .class:not(.class ~ .class) { /* adjustments */ }
      ...but linters seem to hate this syntax for some reason, so your solution is probably more correct :)
      Anyway, I remember using this trick (or a similar version with + instead of ~) to apply a border-top to all vertical s except for the first one, which is another neat application of this subsequent-sibling selector.

  • @gr81matt
    @gr81matt Год назад +3

    Very cool, I was just trying to do something like this the other day...
    I wonder if they will bring similar functionality to :last-child()/:first-child()? You could use that :nth-child(1 of .clr-accent) to find the first pretty easily, but last might be hard to target if you didn't know the content length. Something like :last-child(.clr-accent)

    • @gr81matt
      @gr81matt Год назад +1

      Oh, nevermind... it's there in the link. :nth-last-child()

  • @LeeSmith-cf1vo
    @LeeSmith-cf1vo Год назад +2

    Thats a nice feature, I like it.
    I hate the syntax
    But I like what it can do

  • @stephenprice7502
    @stephenprice7502 Год назад +17

    I love this channel, but I really struggle to remember all the cool things that Kevin teaches us. If he put a cheatsheet in the description of each video it would be awesome.

    • @KevinPowell
      @KevinPowell  Год назад +10

      Too many things for one cheat sheet 😅
      I do have a few, but not very many. Maybe something I could work on though!

    • @amaury_permer
      @amaury_permer Год назад +4

      I always come back when I need to do something haha

    • @kikefuentes5191
      @kikefuentes5191 Год назад

      make your own notes on a file made only for cool/obscure css tools you have to remember, so you always can come back to it on doubt

    • @MrMairu555
      @MrMairu555 Год назад +2

      @@amaury_permer Me too. I also [personally] find Kevin has covered everything I have needed to do (my sites are relatively simple), so only watch his CSS videos. That makes it easy to seach just his channel for a previous video I watched to revise. If I were to watch multiple CSS channels I'd probably forget who taught me something, and would never find it again! 🤣🤣🤣 I do the same with anything I want to "learn".... find the best channel [for me], and then just stick with it. Piximperfect for Adobe Photoshop, for example.

  • @VasilyPavlik
    @VasilyPavlik Год назад

    WOW!!!! This is the one of the most desired CSS update!!!

  • @Kimi-xp2th
    @Kimi-xp2th Год назад

    Thanks for the video.

  • @AmodeusR
    @AmodeusR Год назад

    Thank god it's simple to understand

  • @pascalmaranus
    @pascalmaranus Год назад +3

    Definitely a great and probably long overdue feature. They could have (and in my opinion should have) simply gone for "nth-of-class", though.
    And in all fairness, I have ignored Internet Explorer for years. There's only so much we can do. So as a business, unless specifically requested otherwise (i.e. our government is really far behind technologically), I look at browsers that are 2-3 years old at most.

    • @KevinPowell
      @KevinPowell  Год назад

      This solves the nth-of-class, and opens up a lot more as well, as it can be pretty much any selector, including more complex ones :)

    • @pascalmaranus
      @pascalmaranus Год назад

      @@KevinPowell I get that it covers it mostly. But nth-of-class would be a lot easier to use syntax-wise.
      I’m already already struggling each time I have to use (3n + 1), because I’m so used to working with JS and PHP - where they start at 0 - that I’m always unsure which one it would select 🙈

    • @yestermonth
      @yestermonth Год назад

      @@pascalmaranus And how do you select ID or attribute?

    • @pascalmaranus
      @pascalmaranus Год назад

      @@yestermonth I would assume the same way as always. Just like within :not(), :has(), etc. Although ID selectors should always be unique, so they seem unnecessary here.

  • @erfanvatanparasti2949
    @erfanvatanparasti2949 Год назад

    It is awesome... i didn't know it before👋👍

  • @not_amanullah
    @not_amanullah 11 месяцев назад

    Thanks

  • @davien001
    @davien001 Год назад +1

    I just love css.

    • @Milky____
      @Milky____ Год назад

      I hated css till I found his channel

  • @programingwithali2461
    @programingwithali2461 Год назад +1

    Wow

  • @not_amanullah
    @not_amanullah 11 месяцев назад

    This tutorial is helpful ❤

  • @hineko_
    @hineko_ Год назад +1

    in the end they just gonna add js to css

  • @therealsuper5828
    @therealsuper5828 Год назад

    HELL YEAH

  • @ajmalDeveloper
    @ajmalDeveloper Год назад

    Amazing boss

  • @KacperKwinta
    @KacperKwinta Год назад

    really cool

  • @cuongnguyenduy7933
    @cuongnguyenduy7933 Год назад

    Thanks❤

  • @jonsommet
    @jonsommet Год назад

    Just rewrote my code, thanks!

  • @CodecrafterArtemis
    @CodecrafterArtemis Год назад

    *Ode to joy starts playing*
    Seriously, I feel like CSS is getting A LOT of cool new features every year.

  • @adsheff
    @adsheff Год назад

    Does anyone make printable cheat sheets for these new features? Sometimes it would be easier to have it on a piece of paper as you code, rather than a website.

  • @oliver139
    @oliver139 Год назад +1

    OMG, I've misunderstood the usage of :nth-of-type until now..

  • @NOT6248
    @NOT6248 Год назад

    Should I use it now?

  • @penguinxed
    @penguinxed Год назад

    very cool

  • @amrsayed74
    @amrsayed74 Год назад

    Awesome ♥

  • @silasgeerts1736
    @silasgeerts1736 Год назад

    Hello, i like you color theme but i cant find it in vs code so what theme are you jusing(sorry for my gramer id dont speek englisch very well)

  • @micheledellaquila7671
    @micheledellaquila7671 Год назад

    Where Can I find out if this feature is full support or not??

  • @tonyrogers7101
    @tonyrogers7101 Год назад

    🥳

  • @JasonJA88
    @JasonJA88 Год назад

    👍

  • @Akash-xv5sk
    @Akash-xv5sk Год назад +1

    import '@/styles/globals.css' why do we use @ in the beginning? is it just a convention or does it have meaning?

  • @Skw384
    @Skw384 Год назад

    Hi Kevin, do you know why react doesn’t like nth-child and prefer nth-type-of?

  • @TesterAnimal1
    @TesterAnimal1 Год назад

    Actually I want last of type. Can we do that?

  • @sashinger5230
    @sashinger5230 Год назад

    :nth-of-class would have been a more intuitive way to implement it imho.

  • @godnyx117
    @godnyx117 Год назад +4

    Amazing! Can't wait 6 years till Internet Explorer supports this feature so I will be able to use it in production!

    • @KevinPowell
      @KevinPowell  Год назад +2

      IE will never support it, they killed updates to it years ago, and it's officially dead now in that you can't even open it on any machine running Windows 10 or newer, it just opens Edge instead :)

    • @godnyx117
      @godnyx117 Год назад +2

      @@KevinPowell Wow, Kevin I don't believe that you actually took the time to reply to my comment. I was actually actually joking as you explicitly said in your video that browsers move so fast these days so I thought about trolling a bit saying that, lol! In any case, you are awesome!

  • @BoraKucukkara
    @BoraKucukkara Год назад

    background music sia unstoppable

  • @leonkolodner7671
    @leonkolodner7671 Год назад

    Does it work only for children?
    Will it work for decedents from different parents?

  • @portusdelphini
    @portusdelphini Год назад

    Who works in Safari?

  • @thegate8985
    @thegate8985 Год назад +1

    Sorry for being so stupid, but why don't just use another class? I mean, probably your HTML is generated by template engines like Laravel Blade or is contained inside framework components, so you don't have to use those verbose expressions in CSS, you just add a class name once inside needed elements and define styles for it :)

    • @KevinPowell
      @KevinPowell  Год назад

      It depends on the situation, but I think this is one of those things that you won't use too often, but you're *really* happy exists when you do need it.

  • @Atractiondj
    @Atractiondj Год назад

    Finale, matafuka.....

  • @aleattorium
    @aleattorium Год назад

    Wait, Safari already has it?

    • @MrW0rDs
      @MrW0rDs Год назад

      Yeah... That's a first! What's odd is that caniuse shows that it's working starting at iOS 9, I don't know how that's possible.

  • @DaviAreias
    @DaviAreias Год назад

    maybe they should have named it nth-of-class?

    • @KevinPowell
      @KevinPowell  Год назад +1

      This is basically that, but better, since you can do that, or have more complex selectors as well :D

  • @saschab.5154
    @saschab.5154 Год назад

    Two browsers? Which ones? And, can we all just ignore IE and Safari from now on?

    • @KevinPowell
      @KevinPowell  Год назад

      You can ignore IE unless you have pretty specific demographics on your site.
      You can ignore Safari if you don't mind if Kring everyone on an iPhone, since all broswer on iPhone run WebKit under the hood. It's actually ahead on a lot of new features now though, and FF is the one that's falling behind 😔

  • @knghtbrd
    @knghtbrd Год назад +1

    "Already on 80% of browsers" = Chrome. Just Chrome. Rainbow chrome, red chrome, orange chrome, blue chrome, other blue wannabe chrome, it's all chrome now, except for the one browser that isn't, which supports … none of this. Welcome to a world where an ad and spyware company controls whether you can use adblock and privacy extensions. The new CSS is cool I guess/

  • @rickardelimaa
    @rickardelimaa Год назад +1

    Oh, man. Been soo annoyed of how _.class:nth-child_ is interpreted. Finally a solution for that, other than using javascript frameworks (which I use anyways when building a page).

  • @D7460N
    @D7460N Год назад

    VSCode yells at me all the time for valid CSS...

  • @pickmeup20.02
    @pickmeup20.02 Год назад

    2 mins in :0

  • @JimKernix
    @JimKernix Год назад +1

    Why does anyone concern themselves with Interne Explorer? Who are these people with IE and can not update? Are they in a 3rd world country or something? Do they live in a jungle? How is that even possible? Isn't there anyone to tell them to use a different browser? How do their old devices keep working?

    • @Pesthuf
      @Pesthuf Год назад

      Some companies have sysadmins who learned how to lock down IE and only IE 20 years ago and they refuse to let people use other browsers because they don't want to learn something new.

    • @JimKernix
      @JimKernix Год назад

      @@Pesthuf How much longer until they retire or die? Do you think by 2050 we can stop worrying about IE support or do we have to wait for 2100?

    • @KevinPowell
      @KevinPowell  Год назад +2

      Unless you're in a very niche industry (generally medical), you really don't have to worry about it anymore. You can't even open it on Windows 10 machines now, it'll just open Edge if you try.

    • @NathanHedglin
      @NathanHedglin Год назад

      Because money 💰. Many companies have clients that are while companies still on IE 10 and 11

  • @emi1866
    @emi1866 Год назад

    8 seconds in

  • @qwertt14
    @qwertt14 Год назад

    cool