How to make a div in each card item equal in height

Hi guys, I have a layout like the picture below. I want the div which display description are equal in height. How can I handle this case? Here is codesandbox: https://codesandbox.io/p/sandbox/lucid-khorana-8mqt45?file=%2Fsrc%2FApp.js%3A52%2C19
No description
8 Replies
clevermissfox
clevermissfox2mo ago
Subgrid if the support works for your use case
empty
emptyOP2mo ago
Ok. I will look into it
snxxwyy
snxxwyy2mo ago
you could also do something like this:
.card {
display: flex;
flex-direction: column;
}

.card > :has(+ :last-child) {
flex: 1;
}
.card {
display: flex;
flex-direction: column;
}

.card > :has(+ :last-child) {
flex: 1;
}
the second selector essentially says "give anything that is second to last flex: 1;" which will push the last item on all the cards to the bottom since that element is taking all the remaining space. I wrote it like that since it's more dynamic and you don't have to directly select something like .xyz {...}. It'll adapt if you change the html structure. I personally use something like this since i find it more simpler than subgrid but the subgrid solutions works great too.
Jochem
Jochem2mo ago
you'd also have to set the height of the bottom item to something explicitly then, otherwise it'll take up as much space as it needs and no more
snxxwyy
snxxwyy2mo ago
wouldn't you want it to take up as much space as it needs?
Jochem
Jochem2mo ago
the question is how to make the bottom bits of the card take up the same amount across multiple cards not how do I put the last element at the bottom of the card
snxxwyy
snxxwyy2mo ago
oh i read it wrong haha. Well that also comes into play i guess since in the image his content above the last div is all the same size across every card. It'd make sure they align up if one set of content is larger than the others. but if not, then ignore everything i said haha.
LachsDuJour
LachsDuJour2mo ago
or you give the textwrap a min-height of e.g. 3em
Want results from more Discord servers?
Add your server