Having some queries regarding the piece of code provided. Currently, I have a collection of 5 cards displayed in rows of 3 cards each using the styling
grid-template-columns: repeat(3, minmax(200px, 1fr));
. My concern is whether there is a way for the 4th and 5th divs, which represent the remaining two cards, to take up the entire width of their respective rows while equally dividing the remaining space between them. Additionally, if only one card is left, should it occupy the full width of the row? I know we can target these using nth-of-type, but what if the cards are fetched from an API where the specific div numbers aren't known?
body {
max-width: 1440px;
display: grid;
grid-template-columns: repeat(3, minmax(200px, 1fr));
gap: 1rem;
}
.card {
height: 250px;
background-color: orange;
}
<body>
<div class = "card"></div>
<div class = "card"></div>
<div class = "card"></div>
<div class = "card"></div>
<div class = "card"></div>
</body>
The desired output appearance is similar to this image: https://i.sstatic.net/UGoPw.png