I am trying to have a grid with auto-fill columns and at the same time stretch columns when there is leftover space. So I use grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
. This works as expected. But when I tried to limit the maximum size of the columns with grid-template-columns: repeat(auto-fill, minmax(100px, 120px));
it stops working and takes into account only the max size.
The snippet below shows 2 grids with the two configs. Is that an issue with the browser or am I missing something?
#grid1 {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(100px, 120px)); /* not working as expected */
grid-gap: 16px;
}
#grid2 {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); /* working as expected */
grid-gap: 16px;
}
#grid1 > * {
border: 1px solid navy;
height: 100px
}
#grid2 > * {
border: 1px solid green;
height: 100px
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="grid1">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<hr>
<div id="grid2">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>