Subgrid & Container Queries change how we can create layouts

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

КОМЕНТАРІ • 109

  • @gauravkumawat5811
    @gauravkumawat5811 10 місяців тому +23

    It's been 2 years since I started following your channel & I never regretted doing so. I just feel blessed having such a great teacher by my side❤❤. Lots of love to you Kevin. May you get 20M subscribers on UA-cam. Keep up the good work. Supporters like me will always be by your side😊😊

  • @MattDunlapCO
    @MattDunlapCO 10 місяців тому +24

    @KevinPowell this is the best subgrid demo I've seen to date. I think a "can-i-use" video explaining how to decide when a new feature is safe to use would be helpful. Also, maybe a regular segment just reviewing the state of features we're waiting on (color-mix, subgrid, container queries [size and props], anchor positioning) from relative usage to feature ticket progress would be amazing.

    • @KevinPowell
      @KevinPowell  10 місяців тому +13

      So glad that you enjoyed this one :D - Also, a quarterly check-in on the state of new CSS features could be a good idea!

    • @clevermissfox
      @clevermissfox 10 місяців тому +2

      Gah anchor positioning is gonna be 🔥

  • @Dunktastic17
    @Dunktastic17 10 місяців тому +11

    Very exciting to see all these new CSS features in action! Awesome tutorial!

  • @safie01
    @safie01 9 місяців тому +1

    Que satisfatório ver os items se ajustando, ver tudo funcionando assim me deixa "🥺 I'm amazing".

  • @MM_Sheehan
    @MM_Sheehan 10 місяців тому

    One of the best things about watching these videos is catching Kevin's excitement about new features. Don't ever change.

  • @daveden2
    @daveden2 10 місяців тому +8

    wow, I never thought about using the grid-auto-rows like that... coupled with the subgrid.
    I'm learning a lot from Kevin every day

  • @winningtech5
    @winningtech5 10 місяців тому +3

    love how he uses, the latest css properties now.
    i watch your videos but when i start coding i forget about these new features and fall back to the old way i write css.

  • @gknt7234
    @gknt7234 8 місяців тому

    One of the best CSS videos in 2023. It's like a recap video, Google should use this on their websites!

  • @vlad_gabor
    @vlad_gabor 10 місяців тому +2

    I've been using flex for most of my work but after seeing this video I might switch to grid and containers.
    Awesome work you've done!

    • @igordasunddas3377
      @igordasunddas3377 10 місяців тому

      Same actually. I really think I have a good understanding of how to get stuff to display nicely using flexbox, even for RTL languages, but this looks very interesting and promising and when I finished the video, I definitely wanted to give another thumbs up to it.
      Awesome work, Kevin!

  • @zsoltoroszlany7172
    @zsoltoroszlany7172 10 місяців тому

    I'm so angry to myself because everything is easy, I understand. But when I need to work with grid, subgrid etc. everything, my knowledge just vanishes. It is frustrating but maybe if I'm going to spend more time with it, it will stick. Thank you @KevinPowell for the greate tutorial.

  • @amaury_permer
    @amaury_permer 10 місяців тому +1

    Is funny that I was working with subgrid yesterday in a similar way and then you upload a video about the same, great content as always!

  • @darvil82
    @darvil82 10 місяців тому

    I never knew how powerful subgrid was until now. Thank you!

  • @VasilyPavlik
    @VasilyPavlik 10 місяців тому

    Ohhhhhh. After each of your videos I walk for hour or two around and think how I can use this knowledge. But today I was searching for this knowledge in many places. And only place I've found all answers is here. How did you know what I wanted?

  • @clevermissfox
    @clevermissfox 10 місяців тому +1

    Would love some context and a demo on animating grid some day!

  • @yickysan
    @yickysan 10 місяців тому

    Came from a data science background and fell in love with fronrend because of you.

  • @lukedorny
    @lukedorny 10 місяців тому +2

    I love adding a :last-child {margin-top: auto} to force the price section, for example, to balance out the layout when all cards are the same height. Great video.

  • @danielgago-sk
    @danielgago-sk 10 місяців тому

    Perfect. Subgrid and 100dvh ist perfect solution for many of my problems with design or displaing web page on mobile devices... 👍

  • @bopuc
    @bopuc 10 місяців тому +4

    1. Amazing. As someone who had to hack hundreds of layouts in tables back in the days, this is truly tears-of-joy inducing.
    2. Do you have Chromium, WebKit and Gecko running in your brain?! The speed at which you do this is like you are rendering everything in your mind's eye before you type it in haha. (Of course I don't imagine you just start the camera and record but really prep these so you're ready, but still…) ;)

  • @ronpalmer7260
    @ronpalmer7260 10 місяців тому

    I had this issue with my blog post cards. I got it to all line up but it took a lot of guess work and trial and error. I like this solution.

  • @the3rdchief
    @the3rdchief 10 місяців тому +68

    If you watched this video, not knowing what to expect... gather here, please😅

    • @NicCynthia
      @NicCynthia 10 місяців тому +2

      Same here... I searched "learn Css with Kevin Powell" and I got this.. haha let me learn and see what it's got😎

    • @shineLouisShine
      @shineLouisShine 10 місяців тому

      To be honest, it rarely happens, that I'm clicking a 'Clickbait title' (such as "Game Changer" in this case), and think that the bait was justified.
      This one is different in that regard.
      So... Yeah... I didn't know what to expect but I'm very pleased being tempted to land here because the content is truly informative.

  • @daveturnbull7221
    @daveturnbull7221 10 місяців тому

    Miriam Suzanne gave a great explanation/demo of when and why some parts of CSS break over on Learn With Jason. Really interesting talk about how the whole CSS Working Group thing works.

  • @jfftck
    @jfftck 10 місяців тому

    I am so happy for the focus on layouts in CSS instead of the visual aspect - animations, shadows, masking, etc… This was one of the arguments for CSS when it was first introduced, but then I started to feel that the CSS working group was losing focus. Now that layout is more of the focus, I am getting excited about CSS again.

  • @mkm_
    @mkm_ 10 місяців тому

    Really great demo of subgrid and container queries, just the memory refresher I needed. Looking forward to using these features now that they are better supported.

  • @tomapedersen
    @tomapedersen 10 місяців тому

    Around two years ago I was implementing almost the exact same design (image of various height on top, two text boxes with unknown number of lines). Firefox had subgrid then, and I was looking at it while implementing some ugly Javascript and cursing. Very pleased that subgrid is in all browsers now.

    • @anarchodin
      @anarchodin 10 місяців тому

      If it's not useful to ad-tech offering, Chrome is slow to adopt. :)

  • @altaccount648
    @altaccount648 10 місяців тому +1

    I wish CSS had better nesting like SASS, honestly the only reason I don't want to use plain CSS is the below-average nesting.

  • @bentoth4324
    @bentoth4324 10 місяців тому

    If you are using webpack (or worse, Safari) you can use:
    grid-template-columns: repeat(auto-fit, minmax(calc(min(100%, 180px)), 1fr));

  • @clevermissfox
    @clevermissfox 6 місяців тому +2

    Note-
    container-type: inline-size is incompatible with subgrid; they cannot be on the same element

  • @Shaheer-xs5os
    @Shaheer-xs5os 10 місяців тому

    This man is awesome, he always have something new

  • @jadinethomas8935
    @jadinethomas8935 10 місяців тому

    Thank you!!! No more hecking around with Matching heights with JS.

  • @eccenux
    @eccenux 9 місяців тому

    This is a bit of a nit picking comment, but something others may learn from. To get a better structure and wcag/a11y: the product divs should probably be sections with a header on top of the section or with `aria-labeledby`. I know that Kevin probably knows that as he shown good knowledge of a11y in the past 🙂 and in this case it would probably complicate the example. But something worth knowing that the grid in that structure and layout would be a bit "awkward" for screen readers 😉

  • @aram5642
    @aram5642 10 місяців тому +1

    Form layouts will also get simpler, esp. those split into columns with labels on the left

  • @CZghost
    @CZghost 10 місяців тому

    This is so useful for my sharepoint subsite in the making. Thanks.

  • @PacificDev
    @PacificDev 10 місяців тому

    I am always amazed by your videos🎉

  • @cykonetic
    @cykonetic 10 місяців тому

    Nested tables led to a revolution in CSS which now introduces "subgrid"... looks a lot like nested tables to me ...

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

    Dear Kevin and fellow subscribers, if I recall correctly, it was once mentioned in the channel, that DIV is inline according to spec, but block by default browser styles - unanimously. If so, would you please be so kind as to hint where I can confirm the specification default display type for DIV? Thank you.

  • @wojciechbajon
    @wojciechbajon 10 місяців тому

    finally I'm understand subgrid

  • @shineLouisShine
    @shineLouisShine 10 місяців тому

    Great stuff. Thank you

  • @shankar99977
    @shankar99977 10 місяців тому

    @KevinPowell this is amazing... why you don't make videos on "float"? Could you please make video on floats? I watched your old one too...

  • @adeisaac
    @adeisaac 10 місяців тому

    I officially crown thee, "King of CSS" 👑👑👑👑👑

  • @jacobharvey2946
    @jacobharvey2946 10 місяців тому

    I haven’t tried it in a decade… I wonder how all this modern grid stuff would play out with my flexible SVG project I had back in the day. Effectively it was what you see a lot of sites do with their logo (shrinking it when the page scrolls) on steroids. I based the testing on a another, popular experiment at the time that basically used a sprite sheet. I used the object element and CSS connected to the SVG to resize and manipulate logo(s). The object tag allowed for a sort of sub-page effect. End result was whatever the dimensions of the wrapping element affected the SVG.

    • @jacobharvey2946
      @jacobharvey2946 10 місяців тому

      More unrelated, but the first thing I actually thought of when this popped up. I wish I could convince my only freelance client to be more “flexible” with one of the pages on their site. It’s basically a press page where two page spreads, magazine covers, and web articles all live together. Naturally it’s a grid of items. But with all the variations on image sizes, sometimes it being 2 side by side images, and the client’s requirement none of them can be cropped, it’s a pain to deal with. And of course, new, varying sized items, reflow the page and I periodically get asked if there is another way to do it. Every solution I’ve come up with is slapped down.
      Long story short, they want a flexible layout for the modern web, while somehow also having pixel perfect precision, using varying sized elements. 🤦‍♂️

  • @orbitory7936
    @orbitory7936 10 місяців тому

    Can you talk more about container queries, support for them and how can we add support for browsers that don't have it?

  • @ainschy
    @ainschy 10 місяців тому

    Thx, looks great for the future of css design

  • @rahul9704
    @rahul9704 10 місяців тому

    Subgrid was one my most wished for feature since grid landed

  • @pharmokan
    @pharmokan 10 місяців тому

    great vid. but I hate how the cards cut off the image, is there any workaround for that?

  • @djmtype
    @djmtype 10 місяців тому

    Would it be better to use 1/-1 on product row instead of span 3? For example, if you were to introduce another element on the product card, the grid would break because it would need to span 4 rows.

  • @tonyr.6637
    @tonyr.6637 10 місяців тому

    Brilliance all around! Nice to see such a great combo of subgrid and container queries and native CSS nesting!
    Thank you 🙏🏽

    • @KevinPowell
      @KevinPowell  10 місяців тому +1

      Thank you so much! Really generous of you!

  • @clevermissfox
    @clevermissfox 10 місяців тому

    How did I not clock that container queried can be nested within a certain selector.
    I had also just been wondering if a grid items container would be the main wrapper OR it’s specific cell (since width: 100%; ends up being in relation to the cell not the main wrapper) good to have clarification thank you!

  • @Hobbitstomper
    @Hobbitstomper 10 місяців тому

    Chrome: Hold my beer.
    Firefox: Wait, where's my beer?

  • @ScottMackey
    @ScottMackey 10 місяців тому

    Another great video Kevin! Wonder what has changed so that CSS is making so many great changes/enhancements at a fast pace? Given that for over a decade we was stuck with floats for positioning. 🤣 Thanks again.

    • @erickmoya1401
      @erickmoya1401 10 місяців тому +1

      IE was deprecated.

    • @ScottMackey
      @ScottMackey 10 місяців тому

      @@erickmoya1401 yeah kinda weird that we have some form of standards now too.

  • @Asyncsprice
    @Asyncsprice 10 місяців тому

    I loved your part in the scrima front end dev career path!! Do you have any plans to put another little course on there? maybe involve CSS variables or some of this sub-grid stuff!! would be awesome. Any way happy developing!

    • @KevinPowell
      @KevinPowell  10 місяців тому +1

      Really glad that you liked it! Right now I don't have plans for new material there though. It's not a *never* type thing, but nothing planned

  • @heavylog1c
    @heavylog1c 10 місяців тому

    Grids are overcomplicated. Still using flex. Container thingy is pretty cool though.

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

    Hello @kevinPowell. I'm learning html and css in my own, and I'm having a lot of troubles when personalizing the page...on the styling part😅...can you help me

  • @CarlosBronze
    @CarlosBronze 10 місяців тому

    oh wow Subgrid is now Global 79.34% on caniuse. thats in 10 days!

  • @qassimahmed1791
    @qassimahmed1791 10 місяців тому

    Hello i have a question, why does the body or a main or some kind of container gets a height of 0, even though there are contents inside, but they appear outside in the inspection
    Or even sometimes the body does not take the full width of its content, in other words the whole page or so,
    What i want is a way to make sure all my content stays inside their respective containers, and inside the body

  • @nikilragav
    @nikilragav 10 місяців тому

    7:05 so that first row of cards where the text is wrapping onto a second line is actually taller than the second row where the text isn't wrapping, right? What if I want every card to be the same size (big enough so that none of the text overflows

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

    When I don't need the Aside Element and I want it to be Responsive and in the Center with in 480px what should I do?

  • @scottfwalter
    @scottfwalter 10 місяців тому

    Safari seems to have an issue with:
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
    Any thoughts?

  • @webdeveloper4742
    @webdeveloper4742 10 місяців тому

    Kevin keep your volume levels the same in each upload as Google doesn't like variable levels.

  • @paulab9310
    @paulab9310 10 місяців тому

    Kevin I really liked this tutorial and it made me go for subgrid to align the lines of a list of articles. The only issue I have is what happens when you want this card elements or products in your case to be wrappend in an a tag. I want people to be able to click on a the card and be redirected to the actual article. I've sent the a tag for now for the title and the paragraph but it makes my HTML not very DRY. Any suggestions?

    • @danielgago-sk
      @danielgago-sk 10 місяців тому

      js can control clicks on any element or entire block

  • @LaughingInCorner
    @LaughingInCorner 10 місяців тому

    This is great

  • @girabbit
    @girabbit 10 місяців тому

    So the subgrid means that an element that spans multiple columns or rows has its children obey the parent grid. Is that right?

  • @JasonJA88
    @JasonJA88 10 місяців тому +1

    The mobile support is a little better than what is shown on 'Can I use.' On iOS, most browsers are just reskinned Safari, while on Android, Chrome is under the hood.

    • @KevinPowell
      @KevinPowell  10 місяців тому +2

      On iOS every browser is reskinned Safari, as they all have to use webkit. On Android, however, that isn't the case, the can use their normal engine. A lot of the time for mobile, the most important number to look at is when iOS gained support for it, since it's directly linked to the version of iOS, you can know what devices support it or not.

  • @olesejus
    @olesejus 10 місяців тому +2

    Nice demo. However this type of problem its still easy to solve with other solutions. But subgrid will be super useful with tables. Where column width should be dynamic depends on text length. Now to do that is only possible with where table have its own styling problems. Flex would give you different cell length per different row. And with bigger projects there is always many tables. Most common solutions to that is to use event does not look good. Use JS to dynamically count cell width, but becomes slow. Would be interesting if you try to play and maybe demo solutions in some other demo ;)

    • @KevinPowell
      @KevinPowell  10 місяців тому

      How would you solve this problem without subgrid? For the image height, it would work, but not for the lines of text that are either 1 or 2 lines that I had on my titles :) - I'm not sure why we'd need subgrid in a table though, and not just a regular grid? 🤔 - And if we do change the display property of a table we have to be careful because it strips all the semantics of the table away the instant we do that, so we need to add everything back using aria roles (which we can do with JS, manually would be a nightmare).

    • @olesejus
      @olesejus 10 місяців тому

      @@KevinPowell price field in this demo is fixed height. so any flex or grid option with flex: 1 or fr1 for middle header field works fine. I understand the idea you wanted to explain. But that would be more noticeable for traditional horizontal table where you need to sync column width.

    • @calyodelphi124
      @calyodelphi124 10 місяців тому +1

      This will depend on the contexts in which you use when you don't want to use it, because if you need to arrange tabular data, it is always an accessibility best practice to use the tag so that screen readers for the sight-impaired will function properly when reading the contents of the page to the user. But if you're arranging content in some kind of griddy way where we might previously have used or even the 960 grid framework, then the CSS grid module is definitely the way to go.

  • @timgreller
    @timgreller 10 місяців тому

    there is nesting in default CSS now??? How did I miss that lol
    I already knew and used sub-grid, I know about the container queries for some time now. But I was so expecting the code not to work when you started nesting the CSS selectors in a normal CSS file. I was wondering how long it will take you to realize that you are in a CSS not SCSS file. But then it just worked 😂

  • @teacherrameshkumar
    @teacherrameshkumar 10 місяців тому

    At this point of time, could one just rely solely on grid/sub-grid alone and forget about float, flexbox etc?

  • @sawilliams
    @sawilliams 10 місяців тому

    Kevin, How do you know all this stuff!!!!?

  • @spatialoptic
    @spatialoptic 10 місяців тому

    Thank you so much

  • @katlegomonama5824
    @katlegomonama5824 10 місяців тому

    css king

  • @peterl0815
    @peterl0815 10 місяців тому

    Very cool ... but I don't want to change or debug it a half year later ;-)

  • @albertjoanagramontesuero5290
    @albertjoanagramontesuero5290 10 місяців тому +3

    Hi

  • @brandonwebb474
    @brandonwebb474 10 місяців тому

    Hi Kevin!

  • @rand0mtv660
    @rand0mtv660 10 місяців тому

    It's unfortunate that subgrid has only started to gain traction recently. If other browsers implemented it in 2019 when Firefox did, world would be a better place now

    • @KevinPowell
      @KevinPowell  10 місяців тому

      100%, but better late than never 😅

  • @rijine
    @rijine 10 місяців тому

    Cool..

  • @hugodemenez
    @hugodemenez 10 місяців тому

    Awesome

  • @muhammadusmanakram406
    @muhammadusmanakram406 10 місяців тому

    i did not get grid/subgrid at all

  •  10 місяців тому +1

    While impressive I find the whole construct very complex to achieve the effect. You have various styling across multiple elements which for me hurts readibility and maintenance. I personally would avoid subgrid due to this tight coupling. I think 7 out of 10 front end developers would probably balk at maintaining this css while full stack developers would probably not touch it.

    • @KevinPowell
      @KevinPowell  10 місяців тому

      Subgrid is definitely a trade off, you get more control. I could have done the same thing though, without the `grid-auto-rows` and instead simply given the images an actual height and we'd have the same result, but I wanted to explore an alternative. They are much simpler to use in columns than rows though, imo.

  • @zinodavidoff5953
    @zinodavidoff5953 10 місяців тому

    👑

  • @AdrianCBlack
    @AdrianCBlack 10 місяців тому

    is there a pen with this exmple on codepen?

  • @moshpat86
    @moshpat86 10 місяців тому

    GUNDAM ❤️

  • @grinsk3ks
    @grinsk3ks 10 місяців тому

    good as an example, but I wouldn't do that in real world. It's against component based design.

  • @confused_horse
    @confused_horse 10 місяців тому

    What happened at 2:41?

    • @KevinPowell
      @KevinPowell  10 місяців тому +1

      Just a bit of an awkward cut :)

    • @confused_horse
      @confused_horse 10 місяців тому

      @@KevinPowell absolutely great video though! In fact, I've just wasted an hour of everyone at work discussing the concepts you've shown.

  • @calyodelphi124
    @calyodelphi124 10 місяців тому

    WHAT IS THIS WITCHCRAFT
    THIS IS SO COOL 8D

  • @Dead_Goat
    @Dead_Goat 7 місяців тому

    Ehh not really considering you should never use grid, or grids period. We stopped using tables a LONG time ago please do not go back.

  • @GrimChu69
    @GrimChu69 10 місяців тому

    These hacky solutions is why css is so frustrating...

  • @qeqsiquemechanical9041
    @qeqsiquemechanical9041 10 місяців тому

    humanity already has quantum computers with its own cryptography, and webdevs still can't solve div centering and arranging. imagine being so screwed up as a field