How is this possible with CSS only?!

Поділитися
Вставка
  • Опубліковано 4 жов 2024

КОМЕНТАРІ • 126

  • @KevinPowell
    @KevinPowell  2 роки тому +62

    You'll still want to use some proper validation on your forms, but for these client-side hints can make for some big improvements from a UX side of things, and it's just one of the cool things we can do with :has(), it opens up a lot of other doors as well!

    • @KevinPowell
      @KevinPowell  2 роки тому +9

      @Cube Memes I upload and schedule things out in advance ☺️

    • @gambomaster
      @gambomaster 2 роки тому +3

      @@KevinPowell That's cool. The comment you are reading now was scheduled 2 weeks ago by me. 😆

    • @widadtoumi4439
      @widadtoumi4439 2 роки тому +1

      Hello Kevin, can you please do a video about font families in responsive design? like when we build a website with a certain font family, should we change it to roboto when the website is open on a mobile screen ?
      Thank you so much 😊

  • @sharkinahat
    @sharkinahat 2 роки тому +5

    There's always something I learn from these videos. Today I learned that has() is awsome and that a placeholder pseudo-element exists.

  • @djdx2
    @djdx2 2 роки тому +5

    I like this style Kevin, where you and the viewers are learning/experimenting at the same time. Not just you saying this that this that, you are learning as we are!

    • @djdx2
      @djdx2 2 роки тому

      KEVIN LOVED MY COMMENT WWWOOOOOOO

  • @zachjensz
    @zachjensz 2 роки тому +77

    Another good UX addition could be cursor: not-allowed on the button when it's greyed out.

    • @markboots_
      @markboots_ 2 роки тому +12

      and maybe pointer-events to none. (although tabbing and enter will still work)

    • @trinkel8
      @trinkel8 2 роки тому +5

      And maybe disable the button?

    • @mityukov
      @mityukov 2 роки тому +3

      @@trinkel8 is it possible to trigger "disabled" using css? I can only think of having two buttons and toggling each one's "display"..

    • @trinkel8
      @trinkel8 2 роки тому +1

      @@mityukov hmmmmm. Good point. JS is the only option I can think of for that. So, never mind. ☹️

    • @jaideepshekhar4621
      @jaideepshekhar4621 2 роки тому +4

      Can't we just create two buttons, one disabled, and show the proper one depending on whether the form is valid? No js required.

  • @sergeyvolodin5798
    @sergeyvolodin5798 2 роки тому +5

    Hello , Kevin, you create an amazing and nessesary content ) I’m from Russia and I work as a frontend developer. My main problem was how to create really responsive websites without any difficulties and you and your content have helped me to increase the quality of my knowledge about responsive web design. Have a good day, dude 🙂🙂

  • @neoqwerty
    @neoqwerty 2 роки тому +9

    The HAS:() pseudoclass is also supported in Firefox, but you gotta enable it as an experimental configuration! (I was looking for a good workaround to have some of my table headers change background if they used headers in their content, with a rough fallback if "has" isn't supported.)

  • @GerritforBazeja
    @GerritforBazeja Рік тому

    Nice to validate a form this way. Nice upgrade for the form!

  • @JansenTeam
    @JansenTeam 4 місяці тому

    That was interesting! Yes, I would like to see the css for the spinning letters, please.

  • @eugenbleck
    @eugenbleck 2 роки тому

    This was awesome Kevin!

  • @canadianavenger
    @canadianavenger 2 роки тому +4

    Very cool, it's amazing how far CSS has come. Might be an interesting exercise to see if you can re-create it without using the experimental `has` pseudo-class.

    • @KevinPowell
      @KevinPowell  2 роки тому +1

      It's not experimental anymore, it's fully supported in Chrome and Safari :). Should be here soon-ish with FF as well (granted that doesn't mean we can use it in production yet, but it's getting there!)
      As for re-creating it without it, I guess we could use some sort of `label + input:valid` and other stuff like that to get us pretty close :)

    • @canadianavenger
      @canadianavenger 2 роки тому +1

      @@KevinPowell Sorry, by experimental I just meant a feature that wasn't sufficiently supported out in the wild yet. But good to know it is fully adopted, and that all the other browsers should be catching up to support it "soon". Still, I think it might make for an interesting exercise. Thanks again for all the great content, I'm always learning something from your streams.

    • @Xamy-
      @Xamy- 2 роки тому

      @@canadianavenger I’ve tried and I ran into some edge cases IIRC

    • @jaideepshekhar4621
      @jaideepshekhar4621 2 роки тому

      @@KevinPowell Is it supported on the Brave browser?

  • @theconsciousness6082
    @theconsciousness6082 2 роки тому

    Thanks for explaining everything so thoroughly.

  • @VasilyPavlik
    @VasilyPavlik 2 роки тому

    Marvelous as usual! Thank you !

  • @CirTap
    @CirTap 2 роки тому +3

    **don't bother to regex your email fields!** whatever you enter, it's likely incomplete and breaks with intl. address formats, names, and RFC mail extensions.
    HTML provides the email input type for a reason, which performs a validation check against valid email address patterns. It will work better than any random regex you can find or come up.

  • @kierandansey7293
    @kierandansey7293 2 роки тому

    This is really helpful, thank you very much! I have been using js to manage form validation state primarily because of the form being invalid when the page first loads and having to juggle css selectors cross browser is a "pain in the css". But this approach is actually rather simple and logical, as soon as I saw the has(:placeholder-shown) selector it clicked what he was doing. Very clever!

  • @zaktreister1995
    @zaktreister1995 2 роки тому

    Loved this. Keep doing these!

  • @hirendarkarthikeyan6513
    @hirendarkarthikeyan6513 2 роки тому

    Hi Kevin, you are such an inspiration to me and changed my life

  • @CanadianPenny
    @CanadianPenny 2 роки тому

    Definitely the letter flipped thing, please. That's what I clicked on the vid for. :)

  • @ap6471
    @ap6471 2 роки тому

    A true CSS Hero on UA-cam 🥇

  • @mdshohidulislam5836
    @mdshohidulislam5836 2 роки тому

    Amazing to see how things start from scratch ..

  • @ACE46
    @ACE46 Рік тому +1

    19:17 USE "pointer-events: none;" and "pointer-events: auto;" to disable btn in invalid state and enable in valid :)

  • @nathanmiddleton1478
    @nathanmiddleton1478 2 роки тому +1

    Take this with a grain of salt; for performance what's the overhead difference between JS and CSS for this? I know you typically don't nerd out on these things, but it'd be an interesting thing to consider. Also, nothing wrong with more videos breaking down nifty things you see IMO!

  • @mouadhnida4639
    @mouadhnida4639 2 роки тому

    I love seeing notifications from you

  • @tommyandersen4004
    @tommyandersen4004 2 роки тому

    To enable in Firefox, set: `layout.css.has-selector.enabled` in about:config to True.

  • @bilalsalmi4136
    @bilalsalmi4136 2 роки тому +2

    I'm currently learning javascript , but after watching some of your CSS-only video series , I would rethink of the purpose of using js in some cases where it could be done just with CSS . JS is decreasing speed and performance of websites , js forms as calculator compared to mental-math , it's makes us more and more stupid . kevin Powell::after : { content : 'thank you so much for just amazing content' }

    • @claykrr
      @claykrr 2 роки тому

      js helps you understand that there is absolute no limit on for example forums so you can be flexible with css and always know what’s next

    • @kinstar
      @kinstar 2 роки тому

      you still want to keep learning though

  • @kolbecrypto2976
    @kolbecrypto2976 2 роки тому

    Tnx kevin i learned a lot from you❤

  • @markuserdmann1722
    @markuserdmann1722 2 роки тому +3

    Wonderful! We really need :has()! Maybe you can disable your submit button with pointer-events: none while the form is invalid to prevent the submit?

    • @KevinPowell
      @KevinPowell  2 роки тому

      That could work, but it might leave people wondering what's wrong if they haven't filled out all the fields and don't see any errors, so you'd want to be a little careful :)

  • @PrinceKumar-mf3tl
    @PrinceKumar-mf3tl 2 роки тому

    I really appreciate it ❤️☺️. Keep continue.....

  • @donnyestee
    @donnyestee 2 роки тому +1

    Imagine a change request to change to label "Email" to "Email address".
    And then a comment of your UX designer and PO, "it's just changing a label; it shouldn't take longer than a minute".

  • @trinkel8
    @trinkel8 2 роки тому

    Damn. I just finished a form at work and now I want to start over. I checked out the spinning letters in CodePen and it's really quite simple.

  • @thomaskcollins
    @thomaskcollins 2 роки тому +1

    Love this reverse-engineering breakdown approach! Thank you for this. Hope we get more videos in this format. 👍

  • @markboots_
    @markboots_ 2 роки тому +2

    probably Kevin made this tutorial earlier. But last tuesday Chrome v105 is released which includes the :has() selector. So it should work without the flag (make sure you have updated to the latest chrome version)

    • @stephenJpollei
      @stephenJpollei 2 роки тому

      Yes and hopefully FireFox will have has very soon as well. I think it is behind flag at the moment.

    • @CirTap
      @CirTap 2 роки тому +1

      @@stephenJpollei yep: go to about:config and enable `layout.css.has-selector.enabled`

  • @castlemoyle
    @castlemoyle 2 роки тому +1

    If you HAVE to "hide" the characters in a password input, then give the user the option to SHOW the chars as you type. I hate getting locked out of a site because my fat fumble fingers have screwed up "typing" on a phone. Even if you can see the chars in a password, they are encrypted when sent. And hopefully, we know enough to beware of shoulder surfers stealing stuff. (Good comment with 2 samples of unplanned alliteration. grin). Great podcast!

  • @gobideveloper111
    @gobideveloper111 2 роки тому +2

    Please make a detailed video on container query because chrome supporting it.

    • @KevinPowell
      @KevinPowell  2 роки тому +1

      It's on my schedule already :D

  • @bayoutown
    @bayoutown 2 роки тому

    Thanks!

    • @KevinPowell
      @KevinPowell  Рік тому

      Thank you so much (and sorry for missing this until now!)

  • @Morrile1
    @Morrile1 2 роки тому

    Breaking down someone else's code can help others to understand code better, so please keep it up 👍

  • @dankierson
    @dankierson 2 роки тому +2

    All fine but form fields must always be checked on server side even if you have them validated at client side. I like the shake and shimmer 😁

    • @KevinPowell
      @KevinPowell  2 роки тому +2

      100% it needs to be checked server side too! but some UX hints for the user are always nice :)

    • @Xamy-
      @Xamy- 2 роки тому

      I like to think of it as a multi layered approach

    • @arjix8738
      @arjix8738 2 роки тому

      after all, client side validation is nothing
      since any program can send GET and POST requests
      so there is no need to run the browser, aka the validation wont even run

  • @CJ-ff1xq
    @CJ-ff1xq 2 роки тому +3

    Your software engineers were so preoccupied with whether or not they could, they didn't stop to think if they should.

  • @peteharrison3241
    @peteharrison3241 6 місяців тому

    Kevin, in Jhey's code there are styles like this "--word-total:1" Can you explain this, maybe I'm just missing something

  • @himabimdimwim
    @himabimdimwim 2 роки тому

    "if your browser is Firefox you should... Switch-" 😲

  • @QuietWind01
    @QuietWind01 2 роки тому

    Out of curiosity, it seems that the CSS editor allows for SCSS syntax... why not use that for variables at least?
    Possibly because you're showing this to people who may want to try it and don't use SCSS maybe? I would also assume the outcome would remain the same if you did use SCSS variable syntax.
    P.S. I have been using vanilla CSS for years. A few months ago I decided I wanted something different. I wasn't even really thinking about wanting the "new features/syntax", more like, wanted something new to try. I will probably never go back unless I need to. I have noticed that it's so much better. The only downfall for me is that it's compiled and most people probably want ctrl+s to do all the work 🤣 Though I just leave my command line open on my 3rd monitor and just click, up-arrow enter to compile. So usually it's pretty quick after you get used to it

  • @ColossalMcBuzz
    @ColossalMcBuzz 2 роки тому

    For a browser called The New IE, I can't believe Safari has had default support for *has* for about six months now.

    • @Metalmine
      @Metalmine 2 роки тому

      A browser owned and controlled by one company vs a browser created, maintained, and updated based on an open source codebase is very different. It's like comparing the speed of change between and authoritarian government vs a democratic one. The latter might do things slower, even significantly sometimes, but It needs to as it requires multiple consensus.

  • @divinsmathew
    @divinsmathew 2 роки тому

    Could've added a pointer-events: none and cursor: not-allowed to simulate the button disabled state.

  • @vedantkanoujia
    @vedantkanoujia 2 роки тому +1

    But with css framework these things are easily and fastly done for production, if you are free or jobless you can done it with css or html only whole day

  • @peteharrison3241
    @peteharrison3241 6 місяців тому

    how could this become part of a toolset so including a stylesheet would bring this into play with any signup/sign-in form? Maybe this it too big an ask, but having hundreds of snippets it's hard to work out how to genericyfy (spelling) these to use just about anywhere.

  • @fredbluntstoned
    @fredbluntstoned 2 роки тому

    Since this is only for Chrome. It's not CSS, it's a feature of Chrome.
    So if you only have chrome users then you're ok. Otherwise you need to either:
    a. Wait until other browsers are supported.
    b. Make your own version for other browsers that behaves about the same.
    c. Not use this at all.

  • @Qbe_Root
    @Qbe_Root 2 роки тому

    This should be doable without :has by having the form groups be fieldsets. Fieldsets, like forms, will match :valid and :invalid if their contents do, removing the need for :has(:valid) and :has(:invalid). As for :has(:focus), :focus-within should do

  • @MrNickP
    @MrNickP 2 роки тому +2

    Is there anyway to measure performance of a CSS only solution vs a CSS/JS solution?

    • @nomad100hd
      @nomad100hd 2 роки тому

      I'm curious as well!

    • @KevinPowell
      @KevinPowell  2 роки тому +1

      There are ways, but I have no idea what they are 😅. That type of testing is beyond me, but I'll try to look into it and find out how we can do proper testing for that, as it can be pretty important.

  • @cloudsquall88
    @cloudsquall88 2 роки тому

    Does :not(:focus) mean "when losing focus" and "not having focus" at the same time?

    • @Metalmine
      @Metalmine 2 роки тому

      losing focus is an event trigger, not having focus is an object state, since these stylings are detailed for object state, when the state changes, then it gains new properties.

  • @MrNickP
    @MrNickP 2 роки тому +1

    When I was working through this example I implemented the animation control as
    .form-group:has(:invalid:not(:focus):not(:placeholder-shown)) {
    animation: shake 0.65s;
    }
    In this particular scenario, is there an advantage to splitting it?

    • @KevinPowell
      @KevinPowell  2 роки тому

      oh, nice. As long as that works, it's nice having it together :)

  • @thedacian123
    @thedacian123 2 роки тому

    Form :valid sudo class is an experimental one,i mean very new?Thanks!

    • @KevinPowell
      @KevinPowell  2 роки тому +1

      It's been around for a *long* time now!

  • @jasperdiscovers
    @jasperdiscovers 2 роки тому

    i wish firefox has() support for this. it's coming tho!

  • @QwDragon
    @QwDragon 2 роки тому

    Actually :has(:focus) is :focus-within :)

  • @michaelschone3406
    @michaelschone3406 2 роки тому

    ... and if i try to get the password i just need to interact with the css and test the animation till i get the green one? Im wrong at this pt?
    :peace:

  • @avertry9529
    @avertry9529 2 роки тому

    I just updated Brave, which uses Chrome Engine, and :has is now supported.
    do you know what the popup warning is on Jhey's code? I cannot find it. and his code works without issue? The unsupported popup shows in this video too. So I just wonder what we are missing, seeing as you enabled canary experimental?

    • @KevinPowell
      @KevinPowell  2 роки тому

      popup is a new thing that's being trialed. I've read about it, but forget the details.

    • @avertry9529
      @avertry9529 2 роки тому

      @@KevinPowell Thanks

  • @31redorange08
    @31redorange08 2 роки тому

    “JavaScipt” 😉

  • @mariajegan2409
    @mariajegan2409 2 роки тому

    @keyframes shake {
    0%, 100% {
    transform: translateX(0);
    }
    20%, 40%, 60%, 80% {
    transform: translateX(-4%);
    }
    10%, 30%, 50%, 70%, 90% {
    transform: translateX(4%);
    }
    }

  • @ruthlessadmin
    @ruthlessadmin 2 роки тому +1

    I thank gods I do not believe in every day, that I got out of web development. CSS/HTML is absolute insanity. Pure high-level coding HELL.

  • @_lun4r_
    @_lun4r_ 2 роки тому

    Your thumbnail has a typo: "JavaScipt" instead of "JavaScript"

  • @koolmind
    @koolmind 2 роки тому

    Why we have to write :has(:invalid:not(:focus)) instead of :has(:invalid):not(:focus)
    Focus should be a pseudo-class of the input itself, isn't it? :o

    • @Technoph1le
      @Technoph1le 2 роки тому +1

      If we write what you have said, it would be relative to form itself not it's input

    • @AJman14
      @AJman14 2 роки тому +1

      ^
      Explanation: You want to make sure the :invalid input is :not(:focus) instead of the element that :has() the invalid input.

  • @bn5055
    @bn5055 2 роки тому

    I often ask myself where the Javascipt is. I always end up using Javascript instead 😉

  • @mervinmarias9283
    @mervinmarias9283 2 роки тому

    "That's the easy part"

  • @KennethKolano
    @KennethKolano 2 роки тому

    Not really CSS only, this is CSS + HTML5.

  • @keylanoslokj1806
    @keylanoslokj1806 2 роки тому

    What CSS libraries and frameworks are you using?

    • @KevinPowell
      @KevinPowell  2 роки тому

      None 😂. I have my own system using Sass, that is sort of like a framework I guess.

  • @szaboistvan369
    @szaboistvan369 2 роки тому

    Should've removed pointer events for the disabled submit button

    • @KevinPowell
      @KevinPowell  2 роки тому

      That would work, but if the user skips a field and the button is disabled, it might be a bit confusing, it'd be nice to get a tip to ask them to fill out the missing one I think, instead of having to figure out the problem :)

  • @yousseferraki723
    @yousseferraki723 2 роки тому

    , during the second wave..

  • @davivify
    @davivify 2 роки тому

    From what I can tell _:has_ has very low browser support - as of the end of June.

    • @Metalmine
      @Metalmine 2 роки тому

      As of this week, Chrome and Safari both support it I believe, Firefox is coming soon.

  • @leoschuler
    @leoschuler 2 роки тому

    a good artist copy a great artist steals

  • @MrKOHKyPEHT
    @MrKOHKyPEHT 2 роки тому

    Yeah, it's cool, but it's never using at commercial :D

    • @KevinPowell
      @KevinPowell  2 роки тому

      Oh, it's not ready for production yet, but that doesn't mean it never will be! Browser support will be pretty high by the end of the year for :has(), and while you might not want to use this use case, I think it does a nice job of showing what's possible with it :)

  • @IbrahimKwakuDuah
    @IbrahimKwakuDuah Рік тому

    I always tell people: There's no shame in copy and paste

  • @shiekhpalace2401
    @shiekhpalace2401 2 роки тому

    Do you know about kaboom js

    • @KevinPowell
      @KevinPowell  2 роки тому

      I never had, but just looked now! Looks really cool, but I don't do much game stuff.

    • @shiekhpalace2401
      @shiekhpalace2401 2 роки тому

      @@KevinPowell i wanted a complete tutorial of kaboom js because i want to become a game developer

    • @siddiqahmed3274
      @siddiqahmed3274 2 роки тому

      @@shiekhpalace2401 check code with harry

    • @shiekhpalace2401
      @shiekhpalace2401 2 роки тому

      @@siddiqahmed3274 but he had not uploaded full tutorial i wanted full

    • @siddiqahmed3274
      @siddiqahmed3274 2 роки тому

      @@shiekhpalace2401 kevin is not a js guy. You have to find it somewhere else

  • @ShubhamSingh-sn9cy
    @ShubhamSingh-sn9cy 2 роки тому

    I just installed tNice tutorials program and just looking at it makes my brain hurt lol

  • @user-wq9mw2xz3j
    @user-wq9mw2xz3j 2 роки тому

    i dont understand but then again I only have cs:go

  • @ItsMeooooooo
    @ItsMeooooooo 2 роки тому

    I stopped watching as he said: "When you use Firefox, you have to switch Browsers". The main Purpose of a webpage is to deliver Information. All of your fancy shmancy CSS stuff isn't worth to take a look at when its not compatible with all of the browsers.
    The route your are taking here is bring back the old times of "Optimised for Internet Explorer". Are you sure you want them back?

  • @randomdude0nyoutube
    @randomdude0nyoutube 2 роки тому

    Shamelessly stealing this... 🤣🤣🤣🤣 The whole lot of it

  • @yigit2024
    @yigit2024 2 роки тому

    respond to you all in 1 month to see how tNice tutorialngs have evolved if I rember or if soone is interested. My failure is just that - mine. But I

  • @FdWebdesign
    @FdWebdesign 2 роки тому

    Good Job

  • @djekstra
    @djekstra 2 роки тому

    honest with myself. once you find what you really want to acNice tutorialeve in life, try your best to pursue it as soon as possible. im only rn but i

  • @solvedfyi
    @solvedfyi 2 роки тому

    I don't understand why your "look at some codepens" videos are so SO much more popular than your other videos. Makes me wonder what that incentivizes you to make. Not only do the views come but they should be easier to record, just scrolling through pens. But we get far less education from it.