Stop using position absolute - use CSS Grid stacking!

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

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

  • @hroman_codes
    @hroman_codes 18 часов назад +43

    I can't get over the pointer with the middle finger 😆

  • @curtiswilcox808
    @curtiswilcox808 17 часов назад +9

    Great tips on using grid for stacking and the value of `visibility: hidden`.
    Instead of using aria-label on the span, it's better to use . aria-label only works properly on elements with roles that expect a name and even then, client-side machine translation tends not to work on that attribute (but does work on alt attributes).
    Unfortunately, screen readers don't properly respond to the names of elements dynamically changing so it's typically necessary to also have an ARIA live region to announce state changes.

    • @WesBos
      @WesBos  14 часов назад

      good comment - thanks for this! I mentioned a few other places that I'd normally use an aria-live region anyways - but alas out of the scope of this video.

  • @arinjii5745
    @arinjii5745 10 часов назад +4

    Amazing stuff ngl, im the type of person who uses absolute for stacking, but when you mentioned the bigger loading text part.. thats when i realized its dumb to use absolute.
    10/10 video as always :)

  • @thefrey9588
    @thefrey9588 20 часов назад +46

    that cursor icon tho lmao

    • @WesBos
      @WesBos  20 часов назад +14

      button { cursor: url('fav.farm/🖕') 15 0, auto; }

    • @Ss-zg3yj
      @Ss-zg3yj 19 часов назад +5

      Disrespectful to viewers.

    • @WesBos
      @WesBos  19 часов назад +14

      @@Ss-zg3yj intended

    • @couragic
      @couragic 19 часов назад

      @@Ss-zg3yjto himself too 👌

    • @쿵푸허술
      @쿵푸허술 18 часов назад

      ​@@Ss-zg3yjWell at least the content isn't, so...

  • @vladimir_dev
    @vladimir_dev 6 часов назад

    Very cool tips. I remember in the "old days" getting the button's width in JS on every click :)

  • @ste-fa-no
    @ste-fa-no 18 часов назад +2

    Cool that you teach about the accessibility improvements! 💪

  • @sid06
    @sid06 19 часов назад

    Brilliant idea, I was quite envious when I used ZStack in SwiftUI. Didn't realize I could use grid for the same purpose.

  • @kuubeu
    @kuubeu 19 часов назад +2

    minor nitpick: the spinner is still being animated unless it has `display: none`

    • @WesBos
      @WesBos  19 часов назад +4

      I checked - It doesn't trigger any painting when visibility hidden. I don't see the issue?

  • @CoryTheSimmons
    @CoryTheSimmons 14 часов назад

    Nice tip Wes!

  • @Kingsdasdasd
    @Kingsdasdasd 12 часов назад

    Love your beginner javascript course. Do you mind to create another course about react native or a full stack web development course.

    • @WesBos
      @WesBos  11 часов назад

      Planning on another fullstack course next year

    • @Dev-gq5hn
      @Dev-gq5hn 8 часов назад

      @@WesBos do you have road map? so i can see what is your plan for your future courses

  • @gabrieldl2844
    @gabrieldl2844 19 часов назад +1

    wes you're the 🐐

  • @larsfaye292
    @larsfaye292 36 минут назад

    damn this is AWESOME

  • @mike-2342
    @mike-2342 13 часов назад

    Great tip

  • @HeyNoah
    @HeyNoah 17 часов назад

    This is great!

  • @namboozleUK
    @namboozleUK 19 часов назад +5

    This is definitely one of the better examples where there's an advantage over position: absolute;
    The accessabilty conserations in the demo is very good too!

  • @anthonymichael2614
    @anthonymichael2614 20 часов назад +2

    Smart 😊

  • @OnlyADownstat
    @OnlyADownstat 3 часа назад

    love this ...

  • @buildervision7082
    @buildervision7082 8 часов назад +2

    The fact that i didnt see the cursor until i read a comment about it just goes to shows the power that mind when it is only focused on learning.

  • @theether5993
    @theether5993 5 часов назад

    I felt i don't know css 😂

  • @emil.vladev
    @emil.vladev 18 часов назад +2

    We, humans, are close to artificial general intelligence, yet are unable to horizontally align a spinner and some text by default.

    • @WesBos
      @WesBos  14 часов назад +2

      It's actually funny because I could not get Cursor to generate this approach either :\

  • @bones_twisting_sorrow4750
    @bones_twisting_sorrow4750 3 часа назад

    neat

  • @2mbst1
    @2mbst1 18 часов назад

    Love that cursor. :D
    On topic: That's one line shorter than what I've been doing with grid: 1; and then using grid-column and grid-row each to 1 on the children. Noice! Will yoink that for sure.

    • @WesBos
      @WesBos  14 часов назад

      It's a good one - you can also do grid-row: 1 / -1; grid-column: 1 / -1; without defining the area

  • @mrclaytron
    @mrclaytron 4 часа назад +1

    This has to be the most in your face and yet somehow totally discreet flipping of the bird I've ever seen 😂

  • @honkhonkv2236
    @honkhonkv2236 12 часов назад +1

    the damn cursor caught me off guard 😂

  • @Black1991Star
    @Black1991Star 17 часов назад +1

    Your solution increases the size of the html code. Using position:absolute and some .preloader:before you could achieve the same result, much cleaner.
    The more html code, the faster the glaciers melt

    • @WesBos
      @WesBos  14 часов назад +2

      your position absolute wont be able be vertically centered and wont take into account longer loaders. Plus that absolute is absolutely burning up the GPU and melting the penguins more than bitcoin 🤣

  • @okoiful
    @okoiful 19 часов назад +1

    Is this even relevant in the cursor era?

    • @WesBos
      @WesBos  18 часов назад +3

      someones gotta teach it how to do this

    • @SeanLazer
      @SeanLazer 11 часов назад +3

      Yes people still need to know how to do things lol

  • @Ss-zg3yj
    @Ss-zg3yj 19 часов назад

    Jesus Christ, just use Motion library

    • @WesBos
      @WesBos  19 часов назад +15

      Use a motion library to overlap two elements?

    • @Ss-zg3yj
      @Ss-zg3yj 19 часов назад

      @@WesBos Yeah I thought the question was to make button animate to smaller size when spinner showing. Never thought someone will make a drama and a whole video about dummy show/hide

    • @mohammedgamer1710
      @mohammedgamer1710 19 часов назад

      ​​@@Ss-zg3yjDownloading a huge library just to control button size is the actual dummy idea.

    • @WesBos
      @WesBos  19 часов назад +10

      @@Ss-zg3yj Its not drama, we're learning how to best make flexible layouts!

    • @Clem.E
      @Clem.E 19 часов назад +11

      A 1.5 MB library to make a spinner? 😂