10 ms·
Faster Layouts with CSS Grid and Subgrid
- tobr 7y agoFaster as in less time to author or as in better performance?
- dkersten 7y agoI assume the former. From the article: "Don’t let that stop you: CSS Grid has made my layout process faster and simpler, with more flexibility. "
- skyfaller 7y agoBased purely on the article content, it appears to be "less time to author": "CSS Grid has made my layout process faster and simpler, with more flexibility. We can get started with a few basics, and the fallbacks don’t have to be overwhelming"
- eurasiantiger 7y agoGrids and flexbox are on par with CSS tables for layout performance. Slow as hell to reflow.
- miiiiiike 7y agoGood stuff. Keyboard clacking during screencasts is a non-starter for me tho. I really like Jen Simmons's videos on CSS layouts. (https://www.youtube.com/channel/UC7TizprGknbDalbHplROtag/videos https://www.youtube.com/channel/UC7TizprGknbDalbHplROtag/vid...) Before this month, the last time that I made a layout with CSS floats were still in style. When I decided to really learn modern CSS this month even starter videos like "Basics of CSS Grid: The Big Picture (https://www.youtube.com/watch?v=FEnRpy9Xfes)" https://www.youtube.com/watch?v=FEnRpy9Xfes)" were over my head.. I'm a back-end developer, I'd never used Flexbox let alone Grid. As I watched Jen's videos I scribbled down what she was excited about and then started reading "CSS: The Definitive Guide (https://www.amazon.com/CSS-Definitive-Guide-Visual-Presentation/dp/1449393195/)" https://www.amazon.com/CSS-Definitive-Guide-Visual-Presentat... cover to cover. I'm really glad that I watched Jen's videos first. Having some best practices in my head before I learned the mechanics of Flexbox and Grid helped crystallize everything. Now that I'm basically through CSS: TDG I'm re-watching her videos and getting even more out of them.
- Swizec 7y ago> Good stuff. Keyboard clacking during screencasts is a non-starter for me tho. Funny, I often get compliments on the clacking of my mechanical keyboard in screencasts and livecodings. Creates a soothing background noise.
- miiiiiike 7y agoClacks drive me up the wall. Having a table mounted mic in a podcast gets to me too. I can't concentrate if I keep hearing elbows hitting a table through a mic stand. It's more editing work but I like to split out the screen recording, VO, and PTC. Bonus, you can get rid of jump cuts and other weird edits by cutting to the screen recording just before you messed up your line.
- Swizec 7y agoWhat’s VO and PTC? My mic is on a boom with a shock mount so the clacks really are just mellow background noise. I hate the loud bangs too.
- 0xffff2 7y agoVO -> Voice Over I assume. No idea what PTC is.
- mkl 7y agoI think it's "Piece to Camera", which took quite some digging to find!
- danpeddle 7y agoPush to chat, no?
- mkl 7y agoThe context is video creation: "It's more editing work but I like to split out the screen recording, VO, and PTC." Piece to camera is talking directly to the camera, unlike a voice over while showing something else. Makes sense to me, but I'm guessing a bit. How would "push to chat" fit in? I don't recognise it.
- fimdomeio 7y agoPlease take into account current support for subgrid [1]. My first time redoing quite complex checkout table with mobile support was a nightmare. I only realised I needed something more halfway along the process. Found out it was subgrid I was looking for and they figuring out there was no current browser support. But using a oneliner like `grid-template-columns: repeat(auto-fill, minmax(30rem, 1fr));` too almost fully create a grid system is pretty amazing and something you can use right now. 1. https://caniuse.com/#feat=css-subgrid https://caniuse.com/#feat=css-subgrid
- mtarnovan 7y agowow, you're not kidding. only latest FF supports subgrid ?!
- simcop2387 7y agonot latest, but nightly FF. That's a pretty big non-starter.
- miiiiiike 7y agoSupport is coming tho. Always good to hear about what's next.
- weo3dev 7y agoYes - it came out earlier this week or end of last week. But CSS Grid has been available since 2017. So, we are able to still solve a lot of layout issues with grid, than leaning 100% on flexbox. Every tool for its purpose! We have nearly a full toolbox on the CSS side of things. Happiness.
- liminal 7y agoI've gotten a lot of the benefit of subgrid by using display:contents
- kerkeslager 7y agoI've come to prefer flexbox over grid, the main reason being that it gives much more sensible behavior on different screensizes. When you want to lay out for different sizes of screens, grid usually means a completely separate layout inside a media section, while flexbox's wrapping behavior seems to smoothly transition between wide and narrow screens with only a few margin/width adjustments. There may be a sane way to get the same behavior with grid auto-flow, but if there is, I haven't figured it out. One thing I'd like to try, but have never had the budget for, is completely isolated grid layouts for different sizes. That is, all the layout is in mutually-exclusive media sections. This has a higher up-front cost, but I suspect in the long run, the higher up-front cost would be outweighed by having layouts more fine-tuned for the screen sizes, and more decoupled so you don't have to worry about changes in desktop-size layouts affecting mobile-size layouts. Flexbox also has a significantly larger browser share than Grid on CanIUse. Really though, I'm greatly relieved to see browsers start implementing some layout tools that corresponds to how people actually think about layouts. The float years were dark times.
- Vanderson 7y agoGrid and flexbox have different uses and values. I wouldn't give up on grid. There are things it does that Flexbox fails spectacularly at. (absolute layout control for one...) But also flexbox does a few things grid simply cannot. So it's good to know both.
- The_rationalist 7y agoSadly, I haven't been able to find any benchmarck comparing grid vs flexbox, despite layout being a common bottleneck.
- miiiiiike 7y agoThey have different use cases. The rule of thumb is to use Flexbox if you're laying out content along the X or Y axis and Grid if you need to lay it out over both the X and Y axes.
- maxharris 7y agoSo I'm working on a replacement for HTML and CSS. Right now it's written in JavaScript and it renders to canvas. The reason I'm posting here is because you can write your own layout components in my system. So if you have a new idea, instead of waiting years for it to get standardized and supported by the browsers, you can just roll your own idea and run it in anywhere without any fuss. (Flexbox took years to do something that should have only taken days.) Live demo: http://doc-test.maxharris.org/ http://doc-test.maxharris.org/ (NB: it doesn't support mobile touch events yet, so try that out on a desktop browser.) The framework used by the demo: https://github.com/maxharris9/layout https://github.com/maxharris9/layout If you want to get in touch with me about this thing, I'm maxharris9 on twitter.
- maxharris 7y agoIf you're the ones that downvoted me, can you please explain why? I'm dedicating my life full-time to working on this, and I don't understand why this would offend you. If the trouble is about accessibility, please read my README! I care about that, too, and I would love help!
- swsieber 7y agoNot the downvoter, but... I dont think this comment should be here on this post. The only tie-in is layout. It should be a show in instead.
- maxharris 7y agoD'oh! I forgot all about that! I'm not trying to be spammy. I'm just trying to show that there is a completely different way of doing layout.
- deleted 7y ago[deleted]
- techntoke 7y agoJavaScript is like the worst alternative to HTML and CSS when it comes to performance, dependencies and accessibility.
- arminiusreturns 7y agoAll I want is a sticky, permanent header and footer and the rest of the page for text. (without the text going behind the footer/header) Can grid do this? I really don't like using javascript frameworks, I'm trying hard to keep my stuff pure html5/css3.
- wolco 7y agouse the following attr on the element and put it on top for the header and bottom for the footer. position: fixed;
- arminiusreturns 7y agoTo prevent header and footer eating text and nav? Also doesnt using fixed take it out of the grid?
- wolco 7y agoYou don't want those elements part of your grid.
- btbuildem 7y ago.foo { display: grid; grid-template-rows: 10% 80% 10%; height: 100vh; } <div class="foo"> <div>header</div> <div>text</div> <div>footer</div> </div>
- tux1968 7y agoDon't think that has the desired effect; at least if I understood the request properly. The text area won't get a scrollbar when more text is added to fill the view area. It seems in this case you would have to manually ensure that the text you gave could fit in 80% of the screen, or bad things happen visually. Also, the header and footer aren't permanent, they are affected by the entire-page scrollbar.
- 7y ago
- dearue 7y agoReally interesting. Didn't even know that this existed! Will definitely be checking it out and using it in future projects!
- fourthark 7y ago(video)