Тёмный

How is this possible with CSS only?! 

Kevin Powell
Подписаться 947 тыс.
Просмотров 102 тыс.
50% 1

Опубликовано:

 

21 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 126   
@KevinPowell
@KevinPowell 2 года назад
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 года назад
@Cube Memes I upload and schedule things out in advance ☺️
@gambomaster
@gambomaster 2 года назад
@@KevinPowell That's cool. The comment you are reading now was scheduled 2 weeks ago by me. 😆
@widadtoumi4439
@widadtoumi4439 2 года назад
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 😊
@djdx2
@djdx2 2 года назад
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
@sergeyvolodin5798
@sergeyvolodin5798 2 года назад
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 🙂🙂
@sharkinahat
@sharkinahat 2 года назад
There's always something I learn from these videos. Today I learned that has() is awsome and that a placeholder pseudo-element exists.
@zachjensz
@zachjensz 2 года назад
Another good UX addition could be cursor: not-allowed on the button when it's greyed out.
@markboots_
@markboots_ 2 года назад
and maybe pointer-events to none. (although tabbing and enter will still work)
@trinkel8
@trinkel8 2 года назад
And maybe disable the button?
@mityukov
@mityukov 2 года назад
@@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 года назад
@@mityukov hmmmmm. Good point. JS is the only option I can think of for that. So, never mind. ☹️
@jaideepshekhar4621
@jaideepshekhar4621 2 года назад
Can't we just create two buttons, one disabled, and show the proper one depending on whether the form is valid? No js required.
@neoqwerty
@neoqwerty 2 года назад
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.)
@JansenTeam
@JansenTeam 4 месяца назад
That was interesting! Yes, I would like to see the css for the spinning letters, please.
@CirTap
@CirTap 2 года назад
**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.
@GerritforBazeja
@GerritforBazeja Год назад
Nice to validate a form this way. Nice upgrade for the form!
@canadianavenger
@canadianavenger 2 года назад
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 года назад
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 года назад
@@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?
@eugenbleck
@eugenbleck 2 года назад
This was awesome Kevin!
@VasilyPavlik
@VasilyPavlik 2 года назад
Marvelous as usual! Thank you !
@CanadianPenny
@CanadianPenny 2 года назад
Definitely the letter flipped thing, please. That's what I clicked on the vid for. :)
@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!
@bilalsalmi4136
@bilalsalmi4136 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
@nathanmiddleton1478
@nathanmiddleton1478 2 года назад
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!
@theconsciousness6082
@theconsciousness6082 2 года назад
Thanks for explaining everything so thoroughly.
@markuserdmann1722
@markuserdmann1722 2 года назад
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 :)
@hirendarkarthikeyan6513
@hirendarkarthikeyan6513 2 года назад
Hi Kevin, you are such an inspiration to me and changed my life
@mdshohidulislam5836
@mdshohidulislam5836 2 года назад
Amazing to see how things start from scratch ..
@ap6471
@ap6471 2 года назад
A true CSS Hero on RU-vid 🥇
@castlemoyle
@castlemoyle 2 года назад
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!
@donnyestee
@donnyestee 2 года назад
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".
@peteharrison3241
@peteharrison3241 7 месяцев назад
Kevin, in Jhey's code there are styles like this "--word-total:1" Can you explain this, maybe I'm just missing something
@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
@markboots_
@markboots_ 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 года назад
@@stephenJpollei yep: go to about:config and enable `layout.css.has-selector.enabled`
@mouadhnida4639
@mouadhnida4639 2 года назад
I love seeing notifications from you
@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.
@ACE46
@ACE46 2 года назад
19:17 USE "pointer-events: none;" and "pointer-events: auto;" to disable btn in invalid state and enable in valid :)
@tommyandersen4004
@tommyandersen4004 2 года назад
To enable in Firefox, set: `layout.css.has-selector.enabled` in about:config to True.
@kolbecrypto2976
@kolbecrypto2976 2 года назад
Tnx kevin i learned a lot from you❤
@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
@PrinceKumar-mf3tl
@PrinceKumar-mf3tl 2 года назад
I really appreciate it ❤️☺️. Keep continue.....
@MrNickP
@MrNickP 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 года назад
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.
@MrNickP
@MrNickP 2 года назад
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 :)
@gobideveloper111
@gobideveloper111 2 года назад
Please make a detailed video on container query because chrome supporting it.
@KevinPowell
@KevinPowell 2 года назад
It's on my schedule already :D
@dankierson
@dankierson 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 года назад
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
@peteharrison3241
@peteharrison3241 7 месяцев назад
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.
@Morrile1
@Morrile1 2 года назад
Breaking down someone else's code can help others to understand code better, so please keep it up 👍
@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.
@thedacian123
@thedacian123 2 года назад
Form :valid sudo class is an experimental one,i mean very new?Thanks!
@KevinPowell
@KevinPowell 2 года назад
It's been around for a *long* time now!
@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.
@vedantkanoujia
@vedantkanoujia 2 года назад
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
@divinsmathew
@divinsmathew 2 года назад
Could've added a pointer-events: none and cursor: not-allowed to simulate the button disabled state.
@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.
@bayoutown
@bayoutown 2 года назад
Thanks!
@KevinPowell
@KevinPowell 2 года назад
Thank you so much (and sorry for missing this until now!)
@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.
@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
@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:
@thomaskcollins
@thomaskcollins 2 года назад
Love this reverse-engineering breakdown approach! Thank you for this. Hope we get more videos in this format. 👍
@himabimdimwim
@himabimdimwim 2 года назад
"if your browser is Firefox you should... Switch-" 😲
@CJ-ff1xq
@CJ-ff1xq 2 года назад
Your software engineers were so preoccupied with whether or not they could, they didn't stop to think if they should.
@QwDragon
@QwDragon 2 года назад
Actually :has(:focus) is :focus-within :)
@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 года назад
If we write what you have said, it would be relative to form itself not it's input
@AJman14
@AJman14 2 года назад
^ Explanation: You want to make sure the :invalid input is :not(:focus) instead of the element that :has() the invalid input.
@KennethKolano
@KennethKolano 2 года назад
Not really CSS only, this is CSS + HTML5.
@ruthlessadmin
@ruthlessadmin 2 года назад
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.
@jaideepshekhar4621
@jaideepshekhar4621 2 года назад
Because of loc?
@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%); } }
@jasperdiscovers
@jasperdiscovers 2 года назад
i wish firefox has() support for this. it's coming tho!
@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 :)
@31redorange08
@31redorange08 2 года назад
“JavaScipt” 😉
@bn5055
@bn5055 2 года назад
I often ask myself where the Javascipt is. I always end up using Javascript instead 😉
@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.
@_lun4r_
@_lun4r_ 2 года назад
Your thumbnail has a typo: "JavaScipt" instead of "JavaScript"
@leoschuler
@leoschuler 2 года назад
a good artist copy a great artist steals
@mervinmarias9283
@mervinmarias9283 2 года назад
"That's the easy part"
@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 :)
@yousseferraki723
@yousseferraki723 2 года назад
, during the second wave..
@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
@IbrahimKwakuDuah
@IbrahimKwakuDuah Год назад
I always tell people: There's no shame in copy and paste
@user-wq9mw2xz3j
@user-wq9mw2xz3j 2 года назад
i dont understand but then again I only have cs:go
@ShubhamSingh-sn9cy
@ShubhamSingh-sn9cy 2 года назад
I just installed tNice tutorials program and just looking at it makes my brain hurt lol
@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?
@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.
@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
Далее
:has() opens up new possibilities with CSS
14:30
Просмотров 287 тыс.
Как не носить с собой вещи
00:31
7 ways to deal with CSS
6:23
Просмотров 1,1 млн
6 things I wish I knew about CSS when I started
9:09
Просмотров 226 тыс.
Why I Don't Use Else When Programming
10:18
Просмотров 1,2 млн
Top 10 CSS One Liners That Will Blow Your Mind
13:34
Просмотров 971 тыс.
How to create a theme switcher with HTML & CSS
28:21
Просмотров 112 тыс.
Learn flexbox the easy way
34:04
Просмотров 716 тыс.
A look at the CUBE CSS methodology in action
47:09
Просмотров 104 тыс.
Top 10 Javascript One Liners YOU MUST KNOW!
14:16
Просмотров 195 тыс.
Stop using JS for things that CSS can solve
9:13
Просмотров 76 тыс.
Award Winning Animation With Only 20 Lines Of CSS?
6:59
Как не носить с собой вещи
00:31