Automatic grid
←This is the hip grid! It uses min-max
for a fancy flexible layout and is defined bottom-up. Instead of a fixed number of columns, the content defines the grid look, by the minium and the maximum size of the childs and the number childs. It’s almost like a container query. Make your browser window smaller to see how it will add lines and wrap across them fluidly without breakpoints or media-queries.
The optional different min-size classes, .min_m
— .min_xl
are presets for minimum child size. When no class is given, the default min-width is 8rem
. The default maximun width of each container is 1fr
: When only one container is given, it will span across the whole row. There are no presets for the max size, but you can run your own by defining the local CSS vars. You can further customize the grid with the spans, breakpoints and gaps.
.grid-auto(.min_{size})
_grid-auto.scss
Automatic grid with 16 items
Here, with many items the minium size is clearly visible.
No min size
.grid-auto
Medium min size
.grid-auto.min_m
Large min size
.grid-auto.min_l
Extra large min size
.grid-auto.min_xl
Automatic grid with 3 items
This is the same markup as above, only with less items in each grid row. On all large screen viewport the next four rows look the same. Resize your browser to see differences.
No min size
.grid-auto
Medium min size
.grid-auto.min_m
Large min size
.grid-auto.min_l
Extra large min size
.grid-auto.min_xl
Spans and gaps
Add gap-classses, or gap-no to the auto-grid, span-classes on the child elements work as well.
Custom automatic grid
Last not least — you can change the min and max values of the childs using CSS Vars. Match the grid specs to your content. Check out the profile cards example to see this in action.