Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

grid-template-areas solution with Next.js, TailwindCSS, CSS module

Ryo Nakai 50

@sniper-fly

Desktop design screenshot for the Four card feature section coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


What are you most proud of, and what would you do differently next time?

I made various efforts to enhance the reusability of components,

like:

  • storing the card's content information (title, logo, description) as an array of data, allowing it to be flexibly passed as arguments to the card component.
  • using grid-template-area to handle changes in screen width only with the parent element of the card.
  • using round and overflow-hidden class to make cards round.

What challenges did you encounter, and how did you overcome them?

I needed to change the card layout between the mobile and desktop versions, but achieving this with "flex" was challenging, so I decided to use "grid". While it’s possible to achieve the desired layout with grid-row and grid-column, it would require writing different conditional logic for each card, which would reduce the reusability of the component and make it difficult to process the array data using the map function. I wanted the parent element of the cards to have full control over the layout without adding layout-specific classes to each card. Therefore, I used grid-template-areas to allow the parent element to handle the layout adjustments based on screen size. Since grid-template-areas isn't available as a utility in TailwindCSS, I resolved this by using CSS modules.

Community feedback

@YacoubDweik

Posted

Hey Ryo!

Amazing man! it's almost the same as the original design!

I would only say that from 935px to 768px you will see the cards behave differently depending on their text, I mean some of them will have different heights than the other, you can solve this issue for example by giving the p element fixed heights, because they are the problem here, you can give them height = their content + the needed padding || and make the padding 0 || there are some other solutions as well but you should have fixed heights in all cases, you can make the padding responsive using any responsive units, you can also make the font responsive as well using the same technique, but all in all well done man it is amazing and keep it up!

Marked as helpful

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord