Closed ahmarcode closed 1 year ago
Fix the article or fix my understanding
My bad. I used fr
(all remaining space) instead of auto
(content width). The article is OK.
Here's the code:
#listing {
display: grid;
grid-template-columns: repeat(2, auto);
/* grid-template-columns: repeat(2, 1fr); */
/* auto means set width to be content width */
justify-content: space-around;
}
The justify-items just "seemed" like it worked.
All good, this was a false negative. Be careful when using fr
, prefer auto
if content width needs to be considered.
https://css-tricks.com/snippets/css/complete-guide-grid/#prop-justify-content
justify-content: space-between;
didn't work, butjustify-items: center;
worked.