I NEED HELP WITH CREATING CARDS WITH CSS(using flexbox or grids)

I NEED HELP WITH CREATING CARDS WITH CSS. Everytime i create cards, i find it hard for the layout to be same for all cards. For eg:- if the card has title, image, description, tags, button, and if the description is too long in one of the card, them all the alignment of the cards are broken. So can someone please teach me how to properly do it, as I'm really struggling. Here's my portfolio website I'm building. I need help with the project section cards. PORTFOLIO WEBSITE URL : https://rohit-kf.vercel.app IF ANYONE COULD HELP ME, I'LL GREATLY APPRECIATE IT. THANK YOU. 🥺
Rohit K F
Portfolio website generated by Rohit K F
20 Replies
lko
lko•9mo ago
It depends on what you want to achieve
foulmace
foulmaceOP•9mo ago
I want all the inner items to be on same level. Like all card titles, description, etc
foulmace
foulmaceOP•9mo ago
This is how my cards look right now
No description
Chris Bolson
Chris Bolson•9mo ago
One option would be to use grid on the cards and define the specific row heights to ensure that they are always the same.
foulmace
foulmaceOP•9mo ago
So like grid-template-columns: 1fr 1fr 1fr 1fr 1fr Kinda something like that ?
Chris Bolson
Chris Bolson•9mo ago
not columns, rows
foulmace
foulmaceOP•9mo ago
Oh yes... Sorry
Chris Bolson
Chris Bolson•9mo ago
but they would need to be specific heights (eg pixels) as they are separate cards (sub grid would be great here).
lko
lko•9mo ago
If you want them to be all on the same level you have to set an height for each one of them, for example like this
No description
foulmace
foulmaceOP•9mo ago
I suck at subgrids.... Like... I have no clue bout it.
Chris Bolson
Chris Bolson•9mo ago
The issue you will have is if the content is too long for the assigned height. One solution would be to use line-clamp (as you are using Tailwind)
lko
lko•9mo ago
Subgrid is very recent and is supported in browser but only in recent versions
foulmace
foulmaceOP•9mo ago
I do clip the text in my jsx file for the description.
lko
lko•9mo ago
Around 2023
foulmace
foulmaceOP•9mo ago
I'll try out the GRID method with specific heights and get back to you guys
clevermissfox
clevermissfox•9mo ago
Kevin Powell
YouTube
Subgrid & Container Queries change how we can create layouts
https://kevinpowell.co/courses?utm_campaign=general&utm_source=youtube&utm_medium=containersubgrid 👈 Looking to get better at CSS? I’ve got a range of courses, including several free ones! Container queries and subgrid are now both supported in all evergreen browsers, which is super exciting, and as a bonus, they can work really well together! ...
clevermissfox
clevermissfox•9mo ago
Kevin Powell
YouTube
Easy and more consistent layouts using subgrid
Grid is amazing, but it has it's limitations, many of which are solved with subgrid! Subgrid is only currently supported in Firefox, and this video is part of my Subgrid Awareness Month where I'm looking at raising the profile of subgrid and getting people excited by it! 🔗 Links ✅ New to grid? Start here: https://www.youtube.com/watch?v=v5KzBP...
MarkBoots
MarkBoots•9mo ago
here a quick example with subgrid https://codepen.io/MarkBoots/pen/yLrPoLQ
MarkBoots
MarkBoots•9mo ago
No description
Monztter
Monztter•9mo ago
I usually tackle this with using flex-grow. Check out this codepen I whipped up for you: https://codepen.io/MattBudz/pen/qBwVVNg Notice the card-body has display: flex; and then the card-description has flex-grow: 1 This ensures that the height of all your cards is even with everything above and below the card description maintaining a consistent position in all cards regardless of the height of the description. You can apply the flex-grow to the card-title element also if you anticipate your titles will vary in height.
Want results from more Discord servers?
Add your server