11 ms·
From Bootstrap to CSS Grid
- shrikant 9y agoCompletely off-topic: All five people mentioned as experts on CSS Grid towards the end of this post are women. (I don't have anything else to add, just found this interesting.)
- desireco42 9y agoI welcome our female overlords :). Maybe this might be css that speaks to women.
- eggpy 9y agoIn another blog post they inform us that they have been ranked a Top Company for Women in Technology[0]. I'm not familiar with the Anita Borg Institute that did the ranking, but I think it's great to see anyways. [0] - https://open.nytimes.com/the-new-york-times-ranks-as-a-top-company-for-women-in-technology-22950f5a342 https://open.nytimes.com/the-new-york-times-ranks-as-a-top-c...
- dx034 9y agoIs frontend development generally more dominated by women or just CSS? Any companies driving this in particular?
- bluthru 9y agoIt feels like artificial inclusion via exclusion.
- pdog 9y agoWhat is the advantage of using CSS Grid instead of Flexbox? The Bootstrap v4 already uses Flexbox for its grid system.
- mrborgen 9y agoFlexbox is built for one dimension layouts (e.g. a header), while Grid is built for creating two-dimensional layouts (e.g. an entire page). Use both and you'll get the best of two worlds.
- kumarvvr 9y agoCSS Grid can handle 2D layout requirements. 1D layout requirements in the 2D layout is managed by the flex-box, though the same can be easily be done with a nested CSS Grid.
- maxx 9y agoThe question is not Grid or Flexbox. You can (and will) use both.
- mrborgen 9y ago"It took about three lines of CSS to write the grid layout I wanted, and I wanted to live in the bright and beautiful future where layout is always that simple." This is so spot on. I've met many developers who tend to think Bootstrap is easier, but that's usually because they haven't experienced this part of CSS Grid. Just add a couple of lines and you have a very powerful grid layout. I wrote an article on Bootstrap vs. CSS Grid a few weeks ago btw. Feel free to check it out: https://hackernoon.com/how-css-grid-beats-bootstrap-85d5881cf163 https://hackernoon.com/how-css-grid-beats-bootstrap-85d5881c... And here is a link to my free CSS Grid course, in case you're interested in learning it: https://scrimba.com/g/gR8PTE https://scrimba.com/g/gR8PTE
- tnolet 9y agoNot arguing the usefulness of CSS Grid, but Bootstrap is a whole bunch more than just a grid. All the components in Bootstrap kinda work together with the .container .row .col classes and that’s still a crazy useful feature.
- pcurve 9y agoi agree. Bootstrap has wide range of ui components, sass/less, ability to customize, mixin, etc. ability to customize easily via tinkering with variables.less/sass, or customizing the hell out of it by messing with mixin and component less files.
- CharlesW 9y agoPlus, it's not like you can't use CSS Grid on a page that uses Bootstrap.
- michaelbuckbee 9y agoWhat I think goes unrecognized in the design community is what a tremendous skill it is to be able to put together really disparately styled and designed UX elements into a cohesive whole. Pre Bootstrap / Material / whatever - I'd end up with designs that were just incoherent. You'd look at a modal, or a file upload or something and none of them individually were that awful, but as a whole they didn't fit together.
- desireco42 9y agoJust to add what others always mention: CSS Grid and Flexbox are compatible, CSS Grid lays elements in grid, while flexbox handles one dimensional layouts. To create complex layout you need both and should be familiar with both anyway. I think we are so familiar with css/html pain that we can't believe to see light in the end of the tunnel. :)
- angrymouse 9y agoI recently converted my blog to CSS grid. In the past I would have lazily used bootstrap as I've used that for over three years and know the grid inside out. It was a touch intimidating at first. No framework! But it is really quite expressive. It took me 12 lines of CSS to get a traditional blog layout that collapsed on mobiles.
- sinistersnare 9y agoDo you have a link? I am thinking about converting my blog to CSS-Grid, but would like some inspiration.
- angrymouse 9y agoIt is a touch hacky but here it is: https://grillopress.github.io https://grillopress.github.io Code here: https://github.com/GrilloPress/grillopress.github.io?files=1 https://github.com/GrilloPress/grillopress.github.io?files=1 The idea behind my blog is every major article I style slightly differently. Have an upcoming design kanban one where I've played about a bit more with grids to create the boards
- kumarvvr 9y agoWhat I love about the CSS Grid is that it does a really good job of separating content from presentation. I have used it in one project and it's awesome. What I struggled to do with Bootstrap for almost a week, I could do the same with CSS Grid in an afternoon.
- aloukissas 9y agoI'm a recent convert to CSS grid, absolutely love it. There's no dilemma between flexbox + grid; they're complimentary. Just looking forward to full devtools support in Chrome (although Firefox's grid devtools are mighty fine).
- disconnected 9y agoIt's about time the web got a decent layout system. Every UI toolkit that I know of (wxWidgets, Tcl/Tk, Qt) has some form of layout mechanism (box layout, grid layout, etc), and they'd had it for years/decades. On the web though, people have been hacking around this omission for ages with tables and assorted "grid" systems (pure css, bootstrap, etc). The needs for layout management was there for as long as I can remember, and this isn't a particularly tough problem to solve (Tcl/Tk has had "pack" since the late 90s, IIRC). Why the hell did it take so long for the web to come up with a decent layout mechanism?
- masklinn 9y ago> Why the hell did it take so long for the web to come up with a decent layout mechanism? Because CSS wasn't originally intended to handle layout (got knows what was but there you are), the W3C was historically a bit of a shit-show (one would argue it still is) and had internal competitors to CSS (hello XSL-FO), then people finally accepted the inevitable but started with something which wasn't quite actually sufficient (flexbox) and still took multiple years to get it not-completely wrong, then there were multiple competing alternatives for whole-page layout (the XUL-derived Template Layout and Microsoft's Grid). And so we reach 2018, having spent the last 20 years or so doing ad-hoc bits-and-pieces reinventions of half of DSSSL. But it doesn't use S-Expression so I guess that's great.
- thomascgalvin 9y agoWeb development is just starting to catch up to where we were fifteen years ago. Things like type safety, unit testing, and dependency management are still fairly new on the Javascript side of the house, and I'd argue that Maven is lightyears ahead of NPM or pack or gulp or whatever the fuck the kids are using these days. The UI side is even worse. When you compare $todays_web_framework to QT or Swing, it's like dropping into some terrible alternate timeline where the size of a thing on-screen can only be divined by spraying the proper mixture of cattle bones and chicken entrails on a ouija board beneath a blood moon.
- chrisco255 9y agoWe intentionally moved from Qt to Electron for desktop app development. Electron apps look better generally and are far easier to maintain than Qt-based apps. CSS has its warts but it's very expressive these days. Don't even get me started on Swing versus React. A decent set of React components are more declarative, easier to maintain, and faster to develop with than Swing. You also have powerful testing tools in React like Jest snapshots and Enzyme, which allow you to inspect and test the output of your UI in ways that are not straightforward with Swing.
- sandGorgon 9y agois there a ui toolkit for react based on CSS Grid ?
- Bizarro 9y agoCurrently, probably not. I'm using ant design right now and it uses Flexbox as its underlying layout engine. I think Bootstrap 4 is the same. Once they ditch support for IE11, then they'll probably move to CSS Grid, but at that point you really don't need a UI toolkit to be based on CSS Grid. You either just use the css directly, or have a UI toolkit-independent component wrappers around the grid.
- sandGorgon 9y agoWell, I'm looking for component wrappers. For example I'm using quite a bit of semantic-ui today. Makes the job of building interfaces really simple and easy.
- caffodian 9y agoWhat are the preferred solutions for people that are forced to support IE11? I've seen fallback CSS and JavaScript polyfills used.
- leeoniya 9y agoi'm wondering this too. we need to support down to IE11 but i wanna use grid.
- lemonberry 9y agoThis article on the subject is really good: https://www.smashingmagazine.com/2017/11/css-grid-supporting-browsers-without-grid/ https://www.smashingmagazine.com/2017/11/css-grid-supporting...
- Bizarro 9y agoWas wondering the same thing. I wonder if postcss and autoprefixer supports it? https://github.com/postcss/autoprefixer/issues/603 https://github.com/postcss/autoprefixer/issues/603 This comment is from two years ago: But I think I found a solution for everyone: We support Grid by default. If Autoprefixer see that your CSS is too complicated for IE, it will warn you to disable Grid support and use some JS polyfill.
- dmitriid 9y agoI would give PostCSS with Lost Grid[1] a try (though I haven't used Lost Grid extensively). [1] http://lostgrid.org http://lostgrid.org
- pbhjpbhj 9y agoWill there ever be a time when MSIE won't be the limiting factor; seriously thought we'd gotten past "but what about IE".
- buovjaga 9y agoHere's a simple approach: https://www.smashingmagazine.com/2017/06/building-production-ready-css-grid-layout/ https://www.smashingmagazine.com/2017/06/building-production... "Rather than using fallbacks and shims to ensure a design and layout look the same across all browsers, we’d provide the mobile vertical single-column layout to all browsers and then serve up advanced functionality to those browsers and viewport widths that can take advantage of them."
- Zyst 9y agoCan someone illuminate me as to what are some of the reasons that would make someone style with CSS Grid with a Fallback to Bootstrap? Considering you are already writing Bootstrap due to compatibility concerns why not just keep using that? I feel like adding another dependency like this would just create a risk of having design differences pop up over time. Mind you, I don't hate CSS Grid. I really enjoyed learning it, and I look forward to be able to use it in a few years.
- nkozyra 9y ago> Can someone illuminate me as to what are some of the reasons that would make someone style with CSS Grid with a Fallback to Bootstrap? Generous interpretation: graceful upgrade when CSS grid has sufficient browser support. Realistic interpretation: to work with the 'new hot' and not the 'old stodgy'
- chrisco255 9y agoIt's not just "the new hot". Using pure CSS over a JS + CSS library like bootstrap has performance implications for your code. Besides avoiding yet another dependency, native CSS grid renders faster. Also, CSS grid being a native feature, you can use those skills in any project, anywhere, even one that isn't using Bootstrap.
- ak39 9y agoGrids don’t support transition animations yet. One of the reasons I “downgraded” to bootstrap.
- arunitc 9y agoLet alone using CSS Grid. Here in India, I can't even use Flexbox. Thanks to UC Browser having a 30% market share. Sigh, back to those IE 6 days.
- jordache 9y agowhat's the deal with IE11 and CSS Grid? Is it partial support or MS specific notion of CSS Grid? I keeps seeing both sentiments represented with regard to IE.
- jasonbarone 9y agoSo I love CSS Grid very much, but have found myself still wanting/needing masonry-style "Pinterest" layouts, which I haven't been able to do without JavaScript. I've seen many of the CSS column and flexbox hacks, but nothing quite nails it. Anyone have any good ideas here?
- andrei_says_ 9y agoI’ve explored the same issue and masonry is the only solution I’ve found.
- spiralx 9y agoUntil Houdini is available everywhere so that you can hook into the CSS engine and provide your own custom layout managers, I think masonry layouts will always require some JS. Using CSS grids might make the code simpler though. PS I think Smashing Magazine have an overview of Houdini with a masonry layout as an example...
- jonnyscholes 9y agoCSS grid can do this! Sure not as freedom as a JS implementation but its good enough in 95% of scenarios in my experience! https://codepen.io/balazs_sziklai/pen/mOwoLg https://codepen.io/balazs_sziklai/pen/mOwoLg (not my code - just one of the examples on codepen)
- colept 9y agoSorry, but this is not true masonry because the heights of the items are fixed. Masonry layouts have dynamic height elements.
- jonnyscholes 9y agoSorry I just linked to the first one that looked right as I was on the move. Flexible height is definitely possible as we're using it that in prod. Here's another examplei found with working flexible height :) https://codepen.io/Kseso/pen/ZJbEMe/ https://codepen.io/Kseso/pen/ZJbEMe/
- TipVFL 9y agoIt's interesting to now have this, flexbox, and the multi-column module (that I never see anyone talking about). Does anyone know if this can be used for dynamically wrapping columns? Ostensibly flexbox should be able to handle that, but without an explicit height your column will never wrap. I recently needed to implement dynamically wrapping columns and I was able to get 90% of what I needed from the multi column module. However it seems to be really buggy at this point, it often ended up with elements sliced in half or missing. Also, the biggest issue for me was no way to target the columns and prevent reordering. I had sections of text that could be expanded or collapsed, and that would trigger a complete rearrangement of columns. Nasty. I ended up coding my own column system for vertical wrapping, and it was so helpful I was thinking about open-sourcing it, but I'm not sure if CSS grid obviates the need.
- kilburn 9y agoAs you found out, the CSS multi-column module is not very well specified, and browser support is severly lacking in both features and performance. Unfortunately... no, there's no better css only alternative. Grids are not supposed to address that use case. For now you are much better off looking at "masonry" javascript implementations, because they actually work and exhibit better performance than css columns.
- swlkr 9y agoCSS Grid blew me away the first time I saw it. I didn't realize it was ready on the latest browsers. I switched from bootstrap recently to tachyons, this is just another reason to not miss it.
- deleted 9y ago[deleted]
- Bizarro 9y agoHere's a full-length CSS Grid tutorial posted to HN a few days ago. https://medium.freecodecamp.org/heres-my-free-css-grid-course-merry-christmas-3826dd24f098 https://medium.freecodecamp.org/heres-my-free-css-grid-cours...
- jrochkind1 9y agoDoes Grid work in IE 10 or 11? `caniuse` says "partial" support with prefixes in 11. Anyone have experience of how well it works, with prefixes, how "partial" or compatible the support is? > I implemented this CSS Grid progressive enhancement on The New York Times Watching media card component. Users on old browsers see Bootstrap, but users on browsers that support the display: grid property Okay... yeah, I don't want to do that. Workaround with bootstrap or flexbox that don't really do _quite_ what I want as well as grid does... are still better than having to do the workaround _and_ grid, to get all browsers. > You’re absolutely ready to declare display: grid if you’re the only person contributing code. I think it's the other way around. If you have a team big enough to do grid _and_ fallbacks with flexbox or float or whatever, you're ready for grid. If you're one person... you probably don't got time for that! If I got to do the good enough fallback anyway, I'd rather just be done then. At least if you're me. Sadly, so goes CSS improvements. In a couple years I can probably use grid. Hey, at least I can finally use flexbox, which is awesome too!
- Bizarro 9y agoAs I said in another post in this thread, I'm hoping Postcss and the autoprefixer plugin will work with at least IE11. Is IE 10 even relevant these days? It seems that except for very outdated systems, everybody should have been autoupdated to IE 11 by now
- jrochkind1 9y agoIf it works compatibly just with prefixes, that'll be fine. Heck, I don't mind writing the prefixes myself. If it implements an incompatible old version or proprietary standard with too many edge and not-so-edge case differences, that's another story. Anyone have experience? I also did not know that most IE10 users should be auto-updated to IE11, def gonna look into that more thanks.
- gsnedders 9y ago> If it implements an incompatible old version or proprietary standard with too many edge and not-so-edge case differences, that's another story. Anyone have experience? It implements a much earlier draft of the Grid spec, with a number of differences. You can't just throw prefixes on and expect it to work. That said, it might be possible to map 99.9% of cases automatically and have it work.
- ty___ler 9y agoMy breakthrough moment for grid UI development was realizing that all of my layout code for a component is contained in the parent – rather than spread around the children. For example, in bootstrap or some other older layout framework every "column" would need to contain some class or id to style it correctly. So for a 3 column grid you would need to give each element a class setup of something like "column-third". With grid, all that layout logic is moved into a single container "display: grid" element, making it so much easier to add/remove/edit grid items. Even padding is declared in the container element with the "grid-gap" property! It's a small improvement that has immensely increased my developer experience building grid-like UI.
- chiefalchemist 9y agoAnd it makes sense. That is define the properties of the container, not the individual items within it.
- robertkrahn01 9y agoThere were some good links in the article but my no. 1 resource for CSS grid is https://css-tricks.com/snippets/css/complete-guide-grid/ https://css-tricks.com/snippets/css/complete-guide-grid/
- pavel_lishin 9y agoNot relevant to the article, but her avatar is very cool - and apparently she generated it with SVG and stylesheets: https://codepen.io/tallys/pen/mPBBXr https://codepen.io/tallys/pen/mPBBXr
- spaceseaman 9y agoDoes anyone have a link to how to go about generating an image like this? Did the writer hand make the individual polygons or generate it from an image of themselves?
- aeosynth 9y agoIt's possible to generate svgs from images, see https://jmperezperez.com/svg-placeholders/ https://jmperezperez.com/svg-placeholders/
- pavel_lishin 9y agoThat's really cool, but the results don't look much like her avatar. I'm guessing it's really hard to do this without a lot of human input.