Design comparison
Solution retrospective
- I made the card responsive by using a media query and by using fluid design. The card's width automatically adapts to the viewport on mobile screen sizes.
- I used semantic HTML, e.g.
nav
,ul
. - I implemented proper
hover
andfocus-visible
states. - I also used the
q
tag to create the quote.
First, I centered the card with this code:
display: grid; place-content: center;
But that caused the card to shrink. However, the card should have a bigger width on desktop (see mockup). That's why I only centered the card vertically with this code:
display: grid; align-items: center;
and applied a max-width-wrapper
class to the card to center it horizontally and to make it responsive. This technique is explained in this YouTube video.
I think I found a good approach to center the card and to make it responsive (see above). However, let me know if you know a better solution.
Community feedback
- @Leo-yagamiPosted 4 months ago
Im not sure if you know the flexbox technique. You basically set the main-card component to display flex and use align-items and justify content to center the component vertically and horizontally. Something like this:
.social_card{ display: flex; align-items: center; justify-content: center; }
Marked as helpful0@MichaHuhnPosted 4 months ago@Leo-yagami I tried that at first, but flex causes the card to shrink. However, the card should be wider as shown in the mockup. That's why I chose a different approach.
Edit: I just tried your code on the parent element and applied
flex: 1;
to the card. That causes the card to take up the entire width again. Then I can just apply amax-width: 24rem;
as given in the mockup. Now the card is clamped to this max-width and it is responsive on smaller screen sizes. However, in this case we need to add a padding to the parent, so the card doesn't touch the viewport. That could be an approach too.I guess, I still stick to the
max-width-wrapper
technique I described earlier, because it fits the use case and works well.1
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