New CSS Units! Container Query Units explained

  Рет қаралды 62,523

Kevin Powell

Kevin Powell

Күн бұрын

While media queries that look at the viewport size can be useful, today’s web is very component-based, and having to rely on the viewport size is pretty limiting. Luckily, container queries are now a thing!
🔗 Links
✅ Browser support for container queries: caniuse.com/?search=container...
✅ New media query syntax support (look for range syntax in the chart): developer.mozilla.org/en-US/d...
⌚ Timestamps
00:00 - Introduction
00:43 - The very basics
05:53 - A more real-world example
10:08 - The range syntax
11:13 - Named containers
14:37 - Container-type: size
17:46 - Container queries with flexbox and grid
#css
--
Come hang out with other dev's in my Discord Community
💬 / discord
Keep up to date with everything I'm up to
✉ www.kevinpowell.co/newsletter
Come hang out with me live every Monday on Twitch!
📺 / kevinpowellcss
---
Help support my channel
👨‍🎓 Get a course: www.kevinpowell.co/courses
👕 Buy a shirt: teespring.com/stores/making-t...
💖 Support me on Patreon: / kevinpowell
---
My editor: VS Code - code.visualstudio.com/
---
I'm on some other places on the internet too!
If you'd like a behind the scenes and previews of what's coming up on my KZbin channel, make sure to follow me on Instagram and Twitter.
Twitter: / kevinjpowell
Codepen: codepen.io/kevinpowell/
Github: github.com/kevin-powell
---
And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Пікірлер: 112
@rodbrowning
@rodbrowning Жыл бұрын
Awesome video. Css is becoming more and more complete by the years. Thanks for let us up to date ❤️
@zachjensz
@zachjensz Жыл бұрын
Exciting times in the world of CSS!!
@petarkolev6928
@petarkolev6928 Жыл бұрын
Kevin, the CSS lovers are so thankful for having you ❤
@benheidemann3836
@benheidemann3836 Жыл бұрын
Hey Kevin, thanks for making these videos - your love of CSS has helped me fall in love with it too 😍
@chrisicotec7652
@chrisicotec7652 8 ай бұрын
i honestly think container should get its own standalone html tag with some predefined common css declarations... awesome insights as usual, ive learned more about css by bingeing this channel than i did when i was actively studying it
@aditigaur6542
@aditigaur6542 Жыл бұрын
Your channel is way ahead of its time
@adamstuartclark
@adamstuartclark Жыл бұрын
Outstanding work, Kevin. Appreciate your incredibly informative content!
@wfl-junior
@wfl-junior Жыл бұрын
These new units along with the container queries are so cool, and almost already covered by modern browsers, awesome!
@cosmes.l8742
@cosmes.l8742 Жыл бұрын
It's that kind of thing you thought you didn't need, and after seeing it in action you want the support 100% more than anything HAHHA Great video Kevin!
@songhyeonjun2803
@songhyeonjun2803 6 ай бұрын
I am sharing it with my coworkers! These is awesome examples! always thank for the great and easy-to-understand video!
@microcolonel
@microcolonel Жыл бұрын
Won't be too long now until a reasonable vertical-rl layout can be done in CSS. I love the writing-mode-aware units in this, particularly cqb/cqi.
@bogdandanila6306
@bogdandanila6306 Жыл бұрын
Hell Kevin! I think you are making me fall madly & deeply in love with CSS. Thank you!
@deanuziel4545
@deanuziel4545 4 ай бұрын
Great video Kevin! I really love your passion and enthusiasm for CSS Keep it up 😊
@hubyxreds
@hubyxreds Жыл бұрын
Thanks for the tip Kevin! I'll wait for it to be fully supported before using it.
@newnam
@newnam Жыл бұрын
This is great Kevin! Thanks!
@bobobo1673
@bobobo1673 Жыл бұрын
You are amazing explaining those concepts :)
@silvanpaul2531
@silvanpaul2531 7 ай бұрын
i actually needed this today... this is amazing
@fluntimes
@fluntimes Жыл бұрын
Wow. These new features are amazing. I'll have to shift my attention from programming back to design for a bit so I can fully grasp this new game changing tech! Good thing is I only need follow one channel to get the skinny on it all (thanks!)
@knghtbrd
@knghtbrd Жыл бұрын
Mozilla needs to get their asses in gear. Seriously, this is like the third video of Kevin's talking about new stuff that's been in Chrome for a couple of versions now and Firefox hasn't even begun to consider support. Chrome is like 80% of browsers now (WHICH IS DANGEROUS FOR ALL OF US), but the fact is that if Mozilla isn't going to add new features, that number is going to start to get higher, not lower.
@hansheinrich700
@hansheinrich700 Жыл бұрын
Yup, that's a huge problem. From a data privacy point of view Chrome is fucked up. Same goes for most of Googles Products. Unfortunately Firefox is a mess when developing…
@henriqueaguiar9737
@henriqueaguiar9737 Жыл бұрын
Hey, Kevin! Do you plan on doing some content on image optimization and how to get your images ready to be used on websites? Thanks in advance and keep up the great work!
@seannewell397
@seannewell397 Жыл бұрын
Cloudflare has a product for that I hear! SVG support just got added 👨‍🍳💋
@abdulnafay72
@abdulnafay72 Жыл бұрын
Always use webp format for image.
@christophersatterfield4260
@christophersatterfield4260 Жыл бұрын
Compress your images or use webp and also add loading=“lazy” to tag.
@The-Dev-Ninja
@The-Dev-Ninja Жыл бұрын
amazing! 2 different mentalities, we need to know this. is a game changer!
@tacciniStarmo
@tacciniStarmo Жыл бұрын
Hey! Thanks so much for this video!
@fabnricioorellana
@fabnricioorellana Жыл бұрын
woo man thank you so much for this!!
@brentwgraham
@brentwgraham Жыл бұрын
This is awesome, thank you!
@zbigniewiksinski
@zbigniewiksinski Жыл бұрын
yay, more units /s :D
@flyguille
@flyguille Жыл бұрын
it is just what I was looking for yesterday, and before yesterday!!!. I tryed intuitivelly font-size: 5% (for allowing 20 characters horizontally in the box), but, % works as relative measure of the font-size of the parent heritage, nothing to do with box size!. GREAT I found this video.
@NathanHedglin
@NathanHedglin Жыл бұрын
Great video as always.
@AzaB2C
@AzaB2C 7 ай бұрын
Neat. Cheers!
@VASOTELVI
@VASOTELVI 3 ай бұрын
Brilliant! Thnx!
@cristianzwierzynski1305
@cristianzwierzynski1305 Жыл бұрын
Viewing these videos and trying to learn css Best practices from Argentina. Best regards to You an thanks.
@XCanG
@XCanG Жыл бұрын
cqmin is actually awesome! before that I use calc with some vw and vh to make it responsive, but it still had it's downsizes. cqmin is straightforward fix this problem!
@bloozy85
@bloozy85 7 ай бұрын
i like calc for font sizes like calc(1rem + 1vw) but container queries look really interesting
@shittakemushroom3186
@shittakemushroom3186 Жыл бұрын
CRAAAAAZY KEVIN POWELL!
@sharkinahat
@sharkinahat Жыл бұрын
Trick question - what about scrollbars? Do the cq* units work like vh/vw and just assume scrollbars don't exist?
@KevinPowell
@KevinPowell Жыл бұрын
Great question, without testing it my assumption would be yes, it would be the same issue
@GauravKumar-ue7nz
@GauravKumar-ue7nz Жыл бұрын
Awesomeeee
@tmbarral664
@tmbarral664 Жыл бұрын
oh... the T-shirt.... Nicely done ;)
@thewayis_meh987
@thewayis_meh987 Жыл бұрын
Will this be able to adjust font size so that a heading will take up the full container width regardless of character length (within reason)?
@joeldcanfield_spinhead
@joeldcanfield_spinhead Жыл бұрын
It's 4am and I can't sleep, so this may be nonsense, but there's a tickle in the back of my brain about using the min or max to make the layout orientation-aware, especially on phones where the proportions are so different.
@farhan-app
@farhan-app Жыл бұрын
This is so powerful - thank you! Can you do a video about doing media queries using math notations and ranges such as
@KevinPowell
@KevinPowell Жыл бұрын
I'm waiting for movement on Safari on this first, since it's the only one left that we need support from!
@farhan-app
@farhan-app Жыл бұрын
@@KevinPowell 🔥
@frankroos1167
@frankroos1167 Жыл бұрын
This video had me cursing and swearing. Positive curses, though. These units are beyond awesome. Although I can do most of my styling relating to view, it can be a hassle. These units take away the hassle. I hope my users don't start using FireFox, so I won't run into any support issues.
@saaika5922
@saaika5922 Жыл бұрын
So basically its better to go with it or stick to old ones until it will be available on all browsers? btw. is it actually worth going with height anywhere or it was just to show us an example?
@steveportas7961
@steveportas7961 Жыл бұрын
Does anyone know when FF will take this @container out of flagged? Would like to start using in the daily builds.
@deatho0ne587
@deatho0ne587 Жыл бұрын
This seems more important than @container, saying this mostly due to things like clamp() making me go away from @media.
@altus1226
@altus1226 Жыл бұрын
Video games!!! ( I *would* add more ! but...)
@taz2392
@taz2392 Жыл бұрын
Hi, is subgrid supported by all browsers yet?
@tillkammertoens
@tillkammertoens Жыл бұрын
Thanks for the Video! The link in the bio to the other video doesn't work somehow...
@KevinPowell
@KevinPowell Жыл бұрын
Oh wow, the url for the video has a hyphen in it, and it started formatting it as strikethrough in the description! Just updated it to use a link shortener to get around it - bit.ly/containerqueries
@MaakBow
@MaakBow Жыл бұрын
Cool explanation....but can't a lot of these things be done with % size in the content?
@michaelgleason4791
@michaelgleason4791 Жыл бұрын
It's not that I don't love css, it's just that I'm not much of a front-end developer, and I don't know where to start. Bootstrap? Material? Several others I can't remember off the top of my head? Mix and match?
@markogartnar5658
@markogartnar5658 Жыл бұрын
Tailwind
@davidfischer9186
@davidfischer9186 Жыл бұрын
For me work with vanilla css till you can copy some layouts then you'll understand whatever library you use
@Xamy-
@Xamy- Жыл бұрын
Vanilla until you understand the tech :)
@opinetree
@opinetree Жыл бұрын
Just CSS to start. If you don't have base level understanding, libraries and frameworks will add more confusion. With that base understanding, libraries and frameworks are AWESOME to work with, but you want to know HOW they solve problems differently to the vanilla version
@alexjones420
@alexjones420 Жыл бұрын
If you’re just looking to learn css something like MUI is not what you’re looking for. It’s a component library not exactly a css solution. You can still style those components the way you want but at that point you’re really learning MUI and not css. You will learn css along the way of course but majority of the time will be learning about mui. Cheers
@VasilyPavlik
@VasilyPavlik Жыл бұрын
F....k!!! This is exactly what I need right now. (Gone to caniuse to check compatibility......)
@alexgolpe5337
@alexgolpe5337 Жыл бұрын
so container queries is the best for font sizes???
@anneyo5627
@anneyo5627 Жыл бұрын
Hi Kevin, i follow you for some time now and i really love your content. Ive learned so much already. You are such a good teacher. You explain things very well. The only thing I miss is going deeper into JavaScript. Can you recommend somebody perhaps? I really want to learn more about JavaScript also.
@KevinPowell
@KevinPowell Жыл бұрын
WebDevSimplied is great 👍
@anneyo5627
@anneyo5627 Жыл бұрын
@@KevinPowell thank you so much 😊
@ustdkribooche
@ustdkribooche Жыл бұрын
Love it. How do you, do?
@shaikhyamin3464
@shaikhyamin3464 Жыл бұрын
How do you know this new css things? I mean which blog or news you follow?
@adilkevin6220
@adilkevin6220 Жыл бұрын
Hi Kevin, Can you start a one-minute video of the front-end series? Where you will explain every day one concept. If you do so in a year will learn 365 concepts
@waytospergtherebro
@waytospergtherebro Жыл бұрын
And after 365 days you'll be 364 days behind the rest of the world. Shut up.
@maxdevjs3457
@maxdevjs3457 Жыл бұрын
🤯
@alexwhitington7702
@alexwhitington7702 Жыл бұрын
I didn't know the clamp functions were a thing and I'm furious at myself! That's what I get for basing my info on years-old stackoverflow threads 🤦
@DaniDipp
@DaniDipp Жыл бұрын
when you set the image to grow based on the container height with "height: 100cqb", wouldn't "height: 100%" have the same effect?
@microcolonel
@microcolonel Жыл бұрын
When the writing mode is horizontal-tb, yes; but you have no other way to access that value in *other* properties, which is the beauty of this. Also, if the writing mode is different, then the block axis is the *width*, and the inline axis is the height instead.
@WERWOLION
@WERWOLION Жыл бұрын
How use "cqw" in @supports ? @supports (cqw) { with: 30cqw; } ? or else?
@JonathanCampDesigner
@JonathanCampDesigner Жыл бұрын
Que? To quote fawlty towers 🤪
@mqpiffle100
@mqpiffle100 Жыл бұрын
Any idea when this is coming to Firefox?? Thank you for the knowledge bomb!! 💣
@KevinPowell
@KevinPowell Жыл бұрын
It's being worked on, but I don't know the timeline
@clevermissfox
@clevermissfox 7 ай бұрын
Can you use clamp with cqi? Edit: looks like yes!
@quicktastic
@quicktastic Жыл бұрын
What are you using to see the results right in VS Code?
@aonodensetsu
@aonodensetsu Жыл бұрын
it's a browser window on the right
@quicktastic
@quicktastic Жыл бұрын
@@aonodensetsu Ah, OK. It's just that it seems to update instantly so I thought it was built into VS Code. They seem linked somehow the way it updates.
@celia-cj5py
@celia-cj5py Жыл бұрын
@@quicktastic hot reloading is a beautiful thing :)
@TanvirAhmed-ur3kr
@TanvirAhmed-ur3kr Жыл бұрын
It's live server plugin of vs code.
@PalestinianCode
@PalestinianCode Жыл бұрын
wawwww
@sneaky-Jay
@sneaky-Jay Жыл бұрын
There is a drought on CLS topics more in depth than the friggin super simple default examples. I mean like tough to figure motives for CLS when for example it tells you the body or the html tag does you 1.0 CLS. No one tackles them
@fredhair
@fredhair Жыл бұрын
cqmin you're not going to use much??! Really?! Seems like a great way of dynamically sizing container content to avoid overflow.
@crousdioll
@crousdioll Жыл бұрын
I prefer to use it over the rest of the css features (padding, margin, ... etc) better than the font size Thank you very much KEV
@claythomas4433
@claythomas4433 Жыл бұрын
detail because U was so lost, I still am but not as much haha
@NoiseLeGGa
@NoiseLeGGa Жыл бұрын
FML - how many units do you have in total by now? I am now finally switching to the metric system!
@azuma12
@azuma12 Жыл бұрын
Hi you think you can help me with some front end problems like when I decrease width of my website I have menu that I created it just gets overlap over other menu items and I have used grid so how do I make it responsive??
@KevinPowell
@KevinPowell Жыл бұрын
There's a link in my description for my Discord community, I'd suggest asking in there (make sure you include an example of the problem, makes it much easier to solve!)
@azuma12
@azuma12 Жыл бұрын
@@KevinPowell thx a lot I would glad to be a part of it sir
@ahmedomar5460
@ahmedomar5460 Жыл бұрын
Early
@TesterAnimal1
@TesterAnimal1 Жыл бұрын
5cqi where cqi is what?
@TesterAnimal1
@TesterAnimal1 Жыл бұрын
The inline size is about 300px, so 5 of those? Nope. So 5 what exactly?
@TesterAnimal1
@TesterAnimal1 Жыл бұрын
Oh. It’s a percent value. Maybe explain that?
@perkin524
@perkin524 Жыл бұрын
It's a bit like a game - quite fun but not really necessary.
@David-Ray
@David-Ray Жыл бұрын
Really? 2:36
@joeldcanfield_spinhead
@joeldcanfield_spinhead Жыл бұрын
In his head, Kevin probably added "...compared to doing this using any other units available before now."
@kollpotato
@kollpotato Жыл бұрын
potato
@degenyakuza
@degenyakuza Жыл бұрын
Koll Potato
@oaooaoipip2238
@oaooaoipip2238 Жыл бұрын
Css is becoming overcomplicated. Options are good but I think they should be more careful about what they include in CSS as a markup language. If you only make your websites yourself it's good to have al the options in the world but when it comes to improving or changing some one elses css code it gets harder to understand what is happening and why.
@oliver139
@oliver139 Жыл бұрын
Dude..wtf are these LOL
Container Queries are going to change how we make layouts
24:24
Kevin Powell
Рет қаралды 170 М.
Mastering :has() to Expand Your CSS Skills
15:38
Kevin Powell
Рет қаралды 30 М.
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 7 МЛН
Must-have gadget for every toilet! 🤩 #gadget
00:27
GiGaZoom
Рет қаралды 12 МЛН
Learn CSS Grid the easy way
37:04
Kevin Powell
Рет қаралды 879 М.
HTML with Superpowers: An introduction to Web Components
1:56:47
Front-end Development South Africa (FEDSA)
Рет қаралды 698
We can now transition to and from display: none
21:20
Kevin Powell
Рет қаралды 78 М.
Use these instead of vh
6:06
Kevin Powell
Рет қаралды 478 М.
Write better CSS using logical properties
20:40
Kevin Powell
Рет қаралды 50 М.
Intrinsic CSS with Container Queries and Units with Miriam Suzanne
19:33
Use this instead of media queries or container queries
22:11
Kevin Powell
Рет қаралды 39 М.
React Dev, You Need To Know @container!
30:48
Jack Herrington
Рет қаралды 45 М.
Modern CSS Features You Should Know About
27:48
Joy of Code
Рет қаралды 10 М.
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 7 МЛН