245 points · by sysadm1n · 5y ago · 60 comments
On topic: these are great. I am not sure why grid is one of the most useful, yet underutilized set of features in CSS. Could it have something to do with the fact that there are literally a 1000 ways to accomplish the same thing with it? It's been years since their introduction and I am still very much not comfortable and have to use MDN every time I have to do anything.
Is it just just my old age? Am I alone in this?
First time I tried to use grid layout, we had to roll back the changes because it didn't work in IE11... now that IE11 support is being phased out in most places it might be more usable now?
I do agree that the grid stuff is a little too robust. I'm also finding myself looking it all up again every time I need to use it... but maybe I just don't have the muscle memory down yet like I do with flexbox.
Between last year and this year, our IE11 visitors shrank from a few percent (I think it was 5% during the week, under 1 on the weekend…) to under 1, and I got permission to kick IE11 support. Already implemented the first grid and can’t wait to use CSS variables. It’s like I suddenly landed in the future :)
I think it has a lot to do with perceived browser support and lack of familiarity. Perhaps also a bit of CSS fatigue: “I just learned flex bix and that’s good enough.”
The CSS grid still works worse with the printing page breaks than the tricks with the floats and margins.
I've been using CSS since it first [barely] appeared in IE3, but I've been behind on fully getting to know flex and grid. Didn't know about aspect-ratio at all.
Maybe that says more about the amount of attention I've been paying, but I learned a lot from these examples.
I have tried CSS Grid Garden in the past. I don't remember a damn thing from it.
[1] https://css-tricks.com/snippets/css/a-guide-to-flexbox/ [2] https://css-tricks.com/snippets/css/complete-guide-grid/
And Classic Holy Grail Layout is not a one-liner but this:
.ex5 .parent {
display: grid;
grid-template: auto 1fr auto / auto 1fr auto;
}
.ex5 header {
padding: 2rem;
grid-column: 1 / 4;
}
.ex5 .left-side {
grid-column: 1 / 2;
}
.ex5 main {
grid-column: 2 / 3;
}
.ex5 .right-side {
grid-column: 3 / 4;
}
.ex5 footer {
grid-column: 1 / 4;
}
For the note, in Sciter (flow+flex units) that is definable as main {
flow:grid(1 1 1,
2 5 3,
4 4 4);
}
main > :nth-child(5) { /*middle section */
width:*; /* takes all available space */
height:*;
}
https://terrainformatica.com/2018/12/11/10-years-of-flexboxi...The job of assigning elements to their places could also use named areas:
.ex5 .parent {
display: grid;
grid-template: auto 1fr auto / auto 1fr auto;
grid-template-areas: "header header header"
"left main right"
"footer footer footer";
}
.ex5 header {
grid-area: header;
}
.ex5 .left-side {
grid-area: left;
}
.ex5 main {
grid-area: main;
}
.ex5 .right-side {
grid-area: right;
}
.ex5 footer {
grid-area: footer;
}
Or you could lean on auto placement more heavily: in the original code, the left/main/right grid-column declarations are superfluous, and `1 / -1` is arguably clearer than `1 / 4` for the header and footer: .ex5 .parent {
display: grid;
grid-template: auto 1fr auto / auto 1fr auto;
}
.ex5 header,
.ex5 footer {
grid-column: 1 / -1;
} .ex5 {
flow: grid(header header header,
lside main rside,
footer footer footer);
border-spacing: 3px;
}
main { float: "main"; }
footer { float: "footer"; }
In case of Sciter, single property flow and flex units define everything that flexbox and grid can do with 20+ properties. And note: flexbox breaks existing CSS box model, flow/flex units - do not.See: https://terrainformatica.com/w3/flex-layout/flex-vs-flexbox....
This multi-part MDN guide worked for me. Had to read it twice.
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_La...
All the techniques revolve around the flexbox and grid selectors. In that sense, it is a good starting point (or at least, was) for a CSS developer wanting to have the latest tricks in his arsenal.
In fact, the single most important resource I wish for of this kind, would be a reference page that shows all common layouts and tech-stack agnostic examples of popups, overlays, off-canvas sidebars and such using the most up-to-date implementation so we wouldn't have to include a huge CSS framework for something that's a few lines of modern CSS supported by evergreen browsers.
So yes. This is useful to significantly more people than you imagine.