We have a legacy section of tiled items that were done with Flexbox. The container of the items is a ul
:
ul.icon-grid {
display: flex;
flex-wrap: wrap;
list-style: none;
padding-left: 0;
}
And then the items inside are li
:
.icon-swatch__wrapper {
width: 180px;
height: 110px;
text-align: center;
font-size: 12px;
border: 1px solid #ccc;
margin: 5px;
padding: 10px;
}
I had to use a width and height since the tiles have varied content and I needed them to be the same size. Obviously, if I could use css grid I'd have no such problem.
So I am trying to add a scss block inside a @supports
for grid, which although it works the fixed width of the items is throwing off the grid gutters.
@supports (display: grid) {
ul.icon-grid {
display: grid;
grid-gap: 10px;
grid-template-columns: repeat(4, 1fr);
list-style: none;
padding: 0;
.icon-swatch__wrapper, li {
margin: 0;
width: auto;
}
}
}
I tried using width: auto
as you see to remove the previously used width: 180px
for the old flexbox version, but the tiles do not properly size to the grid.
If I remove the width: 180px
from the flexbox version, the grid version looks perfect. But then if someone has a browser that supports flex but not gris, it looks terrible.
How can I basically "remove" the width: 180px
?