Search
Animating CSS Grid (How To + Examples)
25.1.2023
I’m pleased to shine a light on the fact that the CSS grid-template-rows and grid-template-columns properties are now animatable in all major web browsers! Well, CSS Grid has technically supported animations for a long time, as it’s baked right …
Animating CSS Grid (How To + Examples)...
Exploring CSS Grid’s Implicit Grid and Auto-Placement Powers
1.8.2022
When working with CSS Grid, the first thing to do is to set display: grid on the element that we want to be become a grid container. Then we explicitly define the grid using a combination of grid-template-columns, grid-template-rows…
Exploring CSS Grid’s Implicit Grid and Auto-Placement...
You want minmax(10px, 1fr) not 1fr
22.1.2021
There are a lot of grids on the web like this:
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
My message is that what they really should be is:
.grid {
display: grid;
grid-template-columns: repeat(3, minmax(10px, 1fr));
}
Why? In …
The post You want minmax(10px, 1fr)...
Accordion Rows in CSS Grid
23.7.2020
I’d bet grid-template-columns is used about 10× more than grid-template-rows, but maybe everyone has just been missing out. Eric Meyer chucks a bunch of row lines onto his main site layout grid like this:
grid-template-rows: repeat(7, min-content) 1fr repeat(3, min-content);
That way, if...
Just another +1 for subgrid
19.6.2020
I’d say 85% of my grid usage is in one of these two categories…
I just need some pretty basic (probably equal width) columns that ends up being something like like grid-template-columns: repeat(3, minmax(0, 1fr)); to be safe.
Actually doing some real layout where five minutes in...
Equal Width Columns in CSS Grid are Kinda Weird
14.5.2020
Everything is flexible these days. If you write grid-template-columns: 200px 200px 200px;, sure, you’d have equal-width columns, but that’s a rare day. What you usually mean is three columns of equal fluid width.
We’ve got fractional units for that, like grid-template-columns:...
4 CSS Grid Properties (and One Value) for Most of Your Layout Needs
30.3.2020
CSS Grid provides us with a powerful layout system for websites. The CSS-Tricks guide gives you a comprehensive overview of Grid’s properties with layout examples. What we’re going to do here is a reverse approach to show you the smallest possible set of grid properties you need to know to meet...
Responsive Grid Magazine Layout in Just 20 Lines of CSS
25.2.2020
I was recently working on a modern take of the blogroll. The idea was to offer readers a selection of latest posts from those blogs in a magazine-style layout, instead of just popping a list of our favorite blogs in the sidebar.
The easy part was grabbing a list of posts with excerpts from...
Intrinsically Responsive CSS Grid with minmax() and min()
31.7.2019
The most famous line of code to have come out of CSS grid so far is:
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
Without any media queries, that will set up a grid container that has a flexible number of columns. The columns will stretch a little, until there is enough room...
A responsive grid layout with no media queries
9.5.2019
Andy Bell made a really cool demo that shows us how to create a responsive grid layout without any media queries at all. It happens to look like this when you change the size of the browser window:
I think this is a wonderful layout technique that’s just 6 lines (!) of CSS.
.auto-grid...
Where Do You Nest Your Sass Breakpoints?
11.2.2019
I love nesting my @media query breakpoints. It's perhaps the most important feature of Sass to me. Maybe I pick a method and do it like this:
.element {
display: grid;
grid-template-columns: 100px 1fr;
@include breakpoint(baby-bear) {
display: block;
}
}
That's straightforward enough....
Little Tip: Draw Your Grid in ASCII in Your CSS Comments for Quick Reference
9.7.2018
Say you declared a grid like this:
body {
display: grid;
grid-template-columns: min-content 1fr;
grid-template-rows: min-content auto min-content;
}
This depends on content, for sure, but how it's likely to play out is like this:
+---+-------------+
| | |
|...