Easy and more consistent layouts using subgrid

  Рет қаралды 41,443

Kevin Powell

Kevin Powell

Күн бұрын

Grid is amazing, but it has it's limitations, many of which are solved with subgrid! Subgrid is only currently supported in Firefox, and this video is part of my Subgrid Awareness Month where I'm looking at raising the profile of subgrid and getting people excited by it!
🔗 Links
✅ New to grid? Start here: • Creating a nice layout...
✅ Codepen - start: codepen.io/kevinpowell/pen/ZE...
✅ Codepen - end: codepen.io/kevinpowell/pen/Rw...
✅ MDN on subgrid: developer.mozilla.org/en-US/d...
⌚ Timestamps
00:00 - Introduction
00:33 - The problem with normal grid
02:44 - Getting the main grid ready for subgrid
04:15 - Adding subgrid
05:23 - Gap and subgrid
06:40 - Improving our main 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!

Пікірлер: 83
@zachjensz
@zachjensz 2 жыл бұрын
Grandparent Grid
@fuzzypumpkin7743
@fuzzypumpkin7743 2 жыл бұрын
Ok, now I get why it has some advantages over just making each grid area a grid itself. You could do some more faffing with traditional grid to get the same effect, but this is probably clearer/better on more complex pages.
@justinnobles3659
@justinnobles3659 2 жыл бұрын
6:45 grid-template-columns: repeat(auto-fit minmax(6ch, 20ch)) 1fr;
@eotikurac
@eotikurac 3 ай бұрын
oh, yea, that makes so much sense...
@yiannis_p
@yiannis_p Жыл бұрын
Been busting my head for weeks trying to do exactly this and i finally came across your video that solved all my issues! Thank you so much!
@eotikurac
@eotikurac 3 ай бұрын
i would bet you don't remember how the grid works from just glancing at the css. now imagine some other developer looking at it. css grid is a disaster.
@jcespinoza
@jcespinoza 2 жыл бұрын
Loved the Subgrid Awareness Month! 😄😄
@tomasvidal424
@tomasvidal424 2 жыл бұрын
So cool kevin! Keep it up!
@Leyksnal
@Leyksnal 2 жыл бұрын
Thanks Mr Powell
@web-atelier
@web-atelier 8 ай бұрын
Hi Kevin, thanks for this video. I was wondering what to do when you want to define a specific size in the subgrid. For example, you always want an image to be 250px height ?
@briancross4415
@briancross4415 2 жыл бұрын
Subgrid awareness month. I love it.
@johnwayne8059
@johnwayne8059 17 күн бұрын
Interesting!!!😅 Where to find the next part of subgrid? BTW, nice vids kev!😁👍🤟😎
@MrDenertog
@MrDenertog 2 жыл бұрын
subgrid!!!!! @kevin: you can make it work with repeat function like this `repeat(2, minmax(6ch, 20ch) 1fr)` the length parameter is a space separated list (just like grid-auto-columns would work)
@josvelema2362
@josvelema2362 2 жыл бұрын
Nice , that works so good. I would like to see how you would achieve the same layout with grid alone , just to compare and ofcourse to know grid better.
@KevinPowell
@KevinPowell 2 жыл бұрын
I don't think it's possible to be honest... One of the reasons I wish we had subgrid
@1981ilyha
@1981ilyha 2 жыл бұрын
I love grid!!!
@ico0z
@ico0z 2 жыл бұрын
I use display: contents, to make the children of an element to follow grid of its parent.
@char2s476
@char2s476 Жыл бұрын
you just made me learn another awesome css feature!!!
@moreshwarp
@moreshwarp 2 жыл бұрын
Thanks!
@KevinPowell
@KevinPowell 2 жыл бұрын
Thanks a lot!
@drax6094
@drax6094 2 жыл бұрын
I had a couple situations recently where I really wanted to use subgrid for some cards I was creating, I had to do some awkward workarounds instead. I really hope other browsers jump on board :(
@sharafmakahleh4125
@sharafmakahleh4125 2 жыл бұрын
Great video I suggest that you include the word css somewhere in the title/thumbnail, because most people work with css and don't even know it's a thing in css so they don't click the video
@riddixdan5572
@riddixdan5572 2 жыл бұрын
oh god, if this would release, so much stuff would be so much easier. I don't understand what the browsers are waiting for.
@dv4able
@dv4able 2 жыл бұрын
I think it's a challenge to add new tasks to render the page and keep it fast on most devices.
@xXxLYnXxXx
@xXxLYnXxXx 2 жыл бұрын
very nice :) thx
@hussainfaizal8617
@hussainfaizal8617 2 жыл бұрын
this is awesome, but what about using flex put a fixed width ( in %) for the image container so that everything stays in the same fixed width?
@a.miroshin
@a.miroshin Жыл бұрын
I've just though the same way
@kevincooper3834
@kevincooper3834 2 жыл бұрын
What is the css for zooming in and out unnecessarily?
@progressisbeautiful1541
@progressisbeautiful1541 2 жыл бұрын
Safari implementation is expected at the big Apple event 2028.
@davidricebowled
@davidricebowled 2 жыл бұрын
I originally came to comment to say it's easy to repeat the `minmax(6ch, 20ch) 1fr` but that's been covered already. But I'm curious as to how we might persuade browsers other than Firefox to implement subgrid, is there a particular strategy that's recommended? Do we just email Sundar Pichai, or something?
@bs8028
@bs8028 2 жыл бұрын
Did anyone try this with sass ? How it compile to other browsers ? Many we can use it like it’s already implemented:)??
@peacemekka
@peacemekka 2 жыл бұрын
how does this work with `grid-template-areas` ? or is it not possible to do it with areas?
@frankroos1167
@frankroos1167 2 жыл бұрын
If this doesn't turn you on, you either haven't understood it, or you have never made a more complicated layout. Probably both. ...and this is just scratching the surface... I'm gonna need a diving suit! Learning grid just so you can use subgrid once it is supported? NO WAY! Grid is awesome, even without subgrid. If you don't know grid yet, GO LEARN NOW! Subgrid will be a lot of cream on what is already a pretty tasty strawberry.
@dasten123
@dasten123 2 жыл бұрын
interesting!
@MS-gn4gl
@MS-gn4gl 2 жыл бұрын
In the example you showed at 2:37 they do not behave the same - it's pretty obvious the left column is not behaving the same as the right column once it gets narrower. I'm assuming that's due to the subgrid being set at the column level? Is there anyway to counter that and ensure they're constantly the same?
@adamadequate4596
@adamadequate4596 Жыл бұрын
It's because one of the columns has a larger intrinsic size than the other (the longest unbroken word is longer on the left). This means not all 1fr columns will be the same in order to prevent the content overflowing. Outside of this, the columns on the left and right will be the same at all widths until you hit this lower limit. If you really really don't want this to happen you can use minmax(0, 1fr) instead of 1fr, but your content will overflow in that instance instead of becoming unbalanced. Source: Debugging CSS Grid: Part 2: What the Fr(action)?
@VOXGeneration-Freiamt
@VOXGeneration-Freiamt Ай бұрын
Is it working too width the grid-template-rows?
@codedjango
@codedjango 2 жыл бұрын
When is subgrid gonna be integrated with other browsers apart from Firefox? any idea?
@BasicallyWiz
@BasicallyWiz 2 жыл бұрын
The reason Kevin is hosting this "Month of subgrid" is because no browsers plan to implement subgrid, other than Firefox, which has it already implemented.
@sasca854
@sasca854 2 жыл бұрын
They probably don't feel the need to implement it because grid is already fairly esoteric; subgrid probably wouldn't get used much until people become more familiar with grid in general.
@kuldipkumar3363
@kuldipkumar3363 2 жыл бұрын
Can you please tell me how to stop layout breaking when we zoom in or zoom out the browser window please make a video on this topic
@dave6012
@dave6012 2 жыл бұрын
I know I’m not kevin, but in my experience having a good layout at all widths will prevent layout from breaking on zoom. Zooming has the same effect as width shrinking on layout. Also, use rem/em instead of px for all your sizes. Happy coding!
@clevermissfox
@clevermissfox 3 ай бұрын
Which is the video that explores the “gotchas” with grid-template-rows: subgrid ?
@FanniTakacs-ez3dn
@FanniTakacs-ez3dn Ай бұрын
This one for example: kzbin.info/www/bejne/iGjEeZadfsp0iqc
@aram5642
@aram5642 2 жыл бұрын
But we had this before, it was called 😂 But seriously, please do continue with subgrid! And use your Powell to make all browsers subgrid-savvy :)
@fuzzypumpkin7743
@fuzzypumpkin7743 2 жыл бұрын
Nooooo no bringing tables back! :)
@dave6012
@dave6012 2 жыл бұрын
I HAVE THE POWELL!!!
@filippotinnirello
@filippotinnirello Жыл бұрын
tables are independent like grids unless you fix the column width
@MultiHowdoyoudo
@MultiHowdoyoudo 2 жыл бұрын
@Riddixdan oh god, if this would release, so much stuff would be so much easier. I don't understand what the browsers are waiting for. They are waiting for Kevin to cover all of the advantages before releasing it
@Stoney_Eagle
@Stoney_Eagle 2 жыл бұрын
Interesting... Instead of working inward with styling, subgrid works outward. Why is this only implemented in Firefox 😡 My main user base is on Chromium, Safari and Samsung. 😞
@carolmckay5152
@carolmckay5152 5 ай бұрын
grid-template-columns: repeat(2, minmax(6ch, 20ch) 1fr);
@jsuddsjr
@jsuddsjr 2 жыл бұрын
Firefox only. 😭
@KevinPowell
@KevinPowell 2 жыл бұрын
I know 😢
@OzoneGrif
@OzoneGrif 2 жыл бұрын
Only FireFox supports subgrid ?
@SteveRaynerMakes
@SteveRaynerMakes Жыл бұрын
is subgrid supported on all major browsers?
@eotikurac
@eotikurac 3 ай бұрын
yes, but it's a terrible way to build layouts.
@yajirushik2871
@yajirushik2871 2 жыл бұрын
He did it lol
@udoheinz7845
@udoheinz7845 2 жыл бұрын
I am working as an Web Dev and I just can t use grid because we make webistes for big companys and there is still a big nuber of users using ie.... But in a recent project for a smaller company I used it and it works fantastic....
@dave6012
@dave6012 2 жыл бұрын
I work in web dev and we said fuck the IE users a long time ago.
@udoheinz7845
@udoheinz7845 2 жыл бұрын
@@dave6012 I would also love to but sadly the data shows that quite some people use it...
@dave6012
@dave6012 2 жыл бұрын
@@udoheinz7845 that sucks man… I’m glad I work for a forward thinking company.
@udoheinz7845
@udoheinz7845 2 жыл бұрын
@@dave6012 it all good. we joked about having a party when ie support ends in 2022
@KevinPowell
@KevinPowell 2 жыл бұрын
Google, Netflix, Facebook, Twitter, LinkedIn, AWS, and even Microsoft, among many other of the biggest sites on the internet today have already stopped bothering to keep supporting it... It's time to let it go 🙂
@Atractiondj
@Atractiondj 7 ай бұрын
This is all great, but for example, I haven’t found any practical use for subgrids and container queries for a year now. I still think this is absolutely useless while we have Grid and Flex and if you know how they work then you will not have situations where you need these new options. But I do not deny that one day I will find an area where I cannot do without it.
@caitlinpillay3224
@caitlinpillay3224 2 жыл бұрын
cool shirt
@scnix
@scnix 2 жыл бұрын
but subgrid is still unsupported by most browsers :(
@lenarnie2973
@lenarnie2973 2 жыл бұрын
so sad to see subgrid is still not supported by other browsers :/
@Knards
@Knards 2 жыл бұрын
What the heck is 6ch, 20ch?
@jcespinoza
@jcespinoza 2 жыл бұрын
ch is a unit of measurement
@gilsinhonunes
@gilsinhonunes 2 жыл бұрын
Ch stands for character. One ch is the width of the character 0 (zero).
@Knards
@Knards 2 жыл бұрын
@@gilsinhonunes Thank you. Never heard of them
@abhim6380
@abhim6380 2 жыл бұрын
@@gilsinhonunes why does it exist
@gilsinhonunes
@gilsinhonunes 2 жыл бұрын
@@abhim6380 it’s for keeping lines with a good amount of characters so the legibility is good. For example, you can set a max-width of 65ch on all of your paragraphs, no matter what the font-size or font-family you use.
@eotikurac
@eotikurac 3 ай бұрын
so, basically grid is useless (yes, useless) without subgrid, and until recently it was not supported very well. this is what happens when people want to be too clever. i was perfectly comfortable with limitations of floats and display inline block but when flexbox came out, and later grid, i now don't know what layout is possible or not. i cannot tell my designer, hey this doesn't work anymore because the tools are becoming to complex.
@studiosoftmorecambe6879
@studiosoftmorecambe6879 2 жыл бұрын
Have I got this right, we have happily done this with divs for many years so the experts gave us the complication of grid which introduced resizing problems. To get over this they introduced subgrid to make grids behave like divs on their own do - CSS has lost the plot.
@eotikurac
@eotikurac 3 ай бұрын
you're absolutely right. i've been out of the loop for less than two years and i cannot understand any of the new website layouts. it's all cryptic and i would bet not even the people who built it can understand what's going on.
@realist8774
@realist8774 2 жыл бұрын
Pfff, this can be easily done with Hahaha
@vasekcz
@vasekcz 2 жыл бұрын
Ok
@diegooliveira1083
@diegooliveira1083 2 жыл бұрын
ok
@comradecid
@comradecid 2 жыл бұрын
please please please make the bubble of your head smaller or get rid of it. i can't see the code because it's hidden by your face.
@zweisser
@zweisser 2 жыл бұрын
dont see the difference
Creating a robust grid system using subgrid
36:22
Kevin Powell
Рет қаралды 41 М.
Godzilla Attacks Brawl Stars!!!
00:39
Brawl Stars
Рет қаралды 9 МЛН
Кәріс тіріма өзі ?  | Synyptas 3 | 8 серия
24:47
kak budto
Рет қаралды 1,4 МЛН
Buy Feastables, Win Unlimited Money
00:51
MrBeast 2
Рет қаралды 62 МЛН
min-content, max-content, fit-content - intrinsic sizing with CSS
8:52
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
Рет қаралды 873 М.
I never thought of using CSS animations like this before!
10:28
Kevin Powell
Рет қаралды 51 М.
You can't do this without subgrid
10:49
Kevin Powell
Рет қаралды 15 М.
Subgrid & Container Queries change how we can create layouts
21:08
Kevin Powell
Рет қаралды 70 М.
What would you call this layout?
23:11
Kevin Powell
Рет қаралды 27 М.
Simple solutions to responsive typography
9:21
Kevin Powell
Рет қаралды 164 М.
Create an adaptive CSS grid with a max column count!
10:15
Kevin Powell
Рет қаралды 45 М.