Subgrid & Container Queries change how we can create layouts

Поделиться
HTML-код
  • Опубликовано: 12 янв 2025

Комментарии • 111

  • @MattDunlapCO
    @MattDunlapCO Год назад +26

    @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  Год назад +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 Год назад +2

      Gah anchor positioning is gonna be 🔥

  • @gauravkumawat5811
    @gauravkumawat5811 Год назад +25

    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 RUclips. Keep up the good work. Supporters like me will always be by your side😊😊

  • @clevermissfox
    @clevermissfox 10 месяцев назад +3

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

  • @tonyr.6637
    @tonyr.6637 Год назад

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

    • @KevinPowell
      @KevinPowell  Год назад +1

      Thank you so much! Really generous of you!

  • @MM_Sheehan
    @MM_Sheehan Год назад

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

  • @gknt7234
    @gknt7234 Год назад

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

  • @daveden2
    @daveden2 Год назад +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

  • @safie01
    @safie01 Год назад +1

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

  • @vlad_gabor
    @vlad_gabor Год назад +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 Год назад

      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!

  • @amaury_permer
    @amaury_permer Год назад +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!

  • @nicholasgillespie7081
    @nicholasgillespie7081 2 месяца назад

    You're a healer Kevin... Thanks

  • @winningtech5
    @winningtech5 Год назад +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.

  • @yickysan
    @yickysan Год назад

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

  • @alimansimov1929
    @alimansimov1929 2 месяца назад

    Alright, you are truly the CSS King.

  • @darvil82
    @darvil82 Год назад

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

  • @mkm_
    @mkm_ Год назад

    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.

  • @Shaheer-xs5os
    @Shaheer-xs5os Год назад

    This man is awesome, he always have something new

  • @VasilyPavlik
    @VasilyPavlik Год назад

    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?

  • @the3rdchief
    @the3rdchief Год назад +68

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

    • @CynthiaNic_era
      @CynthiaNic_era Год назад +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 Год назад

      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.

  • @CZghost
    @CZghost Год назад

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

  • @LukeDorny
    @LukeDorny Год назад +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.

  • @daveturnbull7221
    @daveturnbull7221 Год назад

    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.

  • @jadinethomas8935
    @jadinethomas8935 Год назад

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

  • @ronpalmer7260
    @ronpalmer7260 Год назад

    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.

  • @danielgago-sk
    @danielgago-sk Год назад

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

  • @tomapedersen
    @tomapedersen Год назад

    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 Год назад

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

  • @clevermissfox
    @clevermissfox Год назад +1

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

  • @nikilragav
    @nikilragav Год назад

    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

  • @PacificDev
    @PacificDev Год назад

    I am always amazed by your videos🎉

  • @zsoltoroszlany
    @zsoltoroszlany Год назад

    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.

  • @jfftck
    @jfftck Год назад

    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.

  • @ainschy
    @ainschy Год назад

    Thx, looks great for the future of css design

  • @bopuc
    @bopuc Год назад +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…) ;)

  • @bentoth4324
    @bentoth4324 Год назад

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

  • @shineLouisShine
    @shineLouisShine Год назад

    Great stuff. Thank you

  • @wojciechbajon
    @wojciechbajon Год назад

    finally I'm understand subgrid

  • @aram5642
    @aram5642 Год назад +1

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

  • @orbitory7936
    @orbitory7936 Год назад

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

  • @clevermissfox
    @clevermissfox Год назад

    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!

  • @djmtype
    @djmtype Год назад

    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.

  • @pharmokan
    @pharmokan Год назад

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

  • @adeisaac
    @adeisaac Год назад

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

  • @altaccount648
    @altaccount648 Год назад +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.

    • @AndyFairlie
      @AndyFairlie 7 дней назад

      You can best CSS selectors now in modern browsers, try it!

  • @parahumanoid
    @parahumanoid 11 месяцев назад

    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.

  • @jacobharvey2946
    @jacobharvey2946 Год назад

    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 Год назад

      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. 🤦‍♂️

  • @ScottMackey
    @ScottMackey Год назад

    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 Год назад +1

      IE was deprecated.

    • @ScottMackey
      @ScottMackey Год назад

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

  • @shankar99977
    @shankar99977 Год назад

    @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...

  • @onitech38
    @onitech38 11 месяцев назад

    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

  • @cykonetic
    @cykonetic Год назад

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

  • @Asyncsprice
    @Asyncsprice Год назад

    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  Год назад +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

  • @paulab9310
    @paulab9310 Год назад

    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 Год назад

      js can control clicks on any element or entire block

  • @eccenux
    @eccenux Год назад

    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 😉

  • @rahul9704
    @rahul9704 Год назад

    Subgrid was one my most wished for feature since grid landed

  • @scottfwalter
    @scottfwalter Год назад

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

  • @djkomp3tenz
    @djkomp3tenz 8 месяцев назад

    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?

  • @qassimahmed1791
    @qassimahmed1791 Год назад

    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

  • @girabbit
    @girabbit Год назад

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

  • @Hobbitstomper
    @Hobbitstomper Год назад

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

  • @LaughingInCorner
    @LaughingInCorner Год назад

    This is great

  • @heavylog1c
    @heavylog1c Год назад

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

  • @sawilliams
    @sawilliams Год назад

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

  • @spatialoptic
    @spatialoptic Год назад

    Thank you so much

  • @timgreller
    @timgreller Год назад

    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 😂

  • @CarlosBronze
    @CarlosBronze Год назад

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

  • @AdrianCBlack
    @AdrianCBlack Год назад

    is there a pen with this exmple on codepen?

  • @teacherrameshkumar
    @teacherrameshkumar Год назад

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

  • @brandonwebb474
    @brandonwebb474 Год назад

    Hi Kevin!

  • @webdeveloper4742
    @webdeveloper4742 Год назад

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

  • @confused_horse
    @confused_horse Год назад

    What happened at 2:41?

    • @KevinPowell
      @KevinPowell  Год назад +1

      Just a bit of an awkward cut :)

    • @confused_horse
      @confused_horse Год назад

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

  • @muhammadusmanakram406
    @muhammadusmanakram406 Год назад

    i did not get grid/subgrid at all

  • @olesejus
    @olesejus Год назад +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  Год назад

      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 Год назад

      @@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 Год назад +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.

  • @hugodemenez
    @hugodemenez Год назад

    Awesome

  • @rand0mtv660
    @rand0mtv660 Год назад

    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  Год назад

      100%, but better late than never 😅

  • @JasonJA88
    @JasonJA88 Год назад +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  Год назад +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.

  • @katlegomonama5824
    @katlegomonama5824 Год назад

    css king

  • @snowandcoal
    @snowandcoal 2 дня назад

    Why the fuck shit like this gets me excited

  • @rijine
    @rijine Год назад

    Cool..

  • @moshpat86
    @moshpat86 Год назад

    GUNDAM ❤️

  • @zinodavidoff5953
    @zinodavidoff5953 Год назад

    👑

  • @albertjoanagramontesuero5290
    @albertjoanagramontesuero5290 Год назад +3

    Hi

  •  Год назад +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  Год назад

      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.

  • @calyodelphi124
    @calyodelphi124 Год назад

    WHAT IS THIS WITCHCRAFT
    THIS IS SO COOL 8D

  • @grinsk3ks
    @grinsk3ks Год назад

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

  • @qeqsiquemechanical9041
    @qeqsiquemechanical9041 Год назад

    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

  • @GrimChu69
    @GrimChu69 Год назад

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

  • @Dead_Goat
    @Dead_Goat 11 месяцев назад

    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.