Design comparison
Solution retrospective
im proud that I was able to use flexbox to solve this problem, despite not being able to get it to look 100% like the design. Next time I would like to use css grid to solve it.
What challenges did you encounter, and how did you overcome them?Not getting the cards to position themselves like in the design.
Community feedback
- @KapteynUniversePosted 22 days ago
Hey Chris, nice job.
You were close, all you need is wrapping card-2 and 3 with another div, a bit spacing (
margin-bottom: 20px;
to card-2 maybe) andalign-items: center;
to the .card-container<div class="card-container"> <div class="card card-1"> ... </div> <div> <div class="card card-2"> ... </div> <div class="card card-3"> ... </div> </div> <div class="card card-4"> ... </div> </div>
.card-container { display: flex; /* flex-wrap: wrap; */ /* I disabled this because just before the media query it was becoming odd, you might wanna change your media query around 820px or 50rem */ justify-content: center; gap: 20px; margin-top: 40px; align-items: center; }
For the icons; you can give flex to each card div and align-self to the icons or you can use grid, absolute/relative positioning.
.card { background-color: white; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); padding: 20px; /* text-align: center; */ /* Texts are not centered on the design */ width: 250px; display: flex; flex-direction: column; justify-content: space-between; /* To have an even spacing between texts and icon */ }
.card img { width: 40px; height: 40px; align-self: flex-end; }
For visual flexbox tricks and other things i recommend you to check this page
Marked as helpful2
Please log in to post a comment
Log in with GitHubJoin 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