As far as I understand, anything flexbox can do, css-grid should also be able to do (usually more verbosely).
Yet I cannot figure out how to mimic a flexbox with an
You need to make use of grid-template-rows which is used to declare the area occupied by each row
where
ul {
list-style-type: none;
padding: 0;
display: grid;
outline: 1px solid red;
height: 200px;
background-color: lime;
grid-template-rows: minmax(1px, auto) minmax(1px, auto) minmax(1px, auto) 1fr;
}
li {
background-color: cornsilk;
}
li:last-of-type {
margin-top: auto;
}
- 1
- 2
- 3
- 4
On a further note, CSS Grid doesn't really replace the need of flexbox. https://css-tricks.com/css-grid-replace-flexbox/