Responsive Card Component Using Media Queries
Design comparison
Solution retrospective
Any clue on how to not use media queries for this simple component?
I thought about using CSS Grid but thought it would overkill for this component. Could a responsive component be possible with Flexbox
Community feedback
- @elaineleungPosted over 2 years ago
Hey Anthony, yes, it's actually possible to make a responsive card component using flexbox and no media queries. What you need is to use
flex-wrap: wrap
and also to specify the flex properties on the children (which in this case are the image and card text content), and lastly, add amax-width
on the card for responsiveness if you need (you probably do). I just wrote up a CodePen to show you how this can be done: https://codepen.io/elaineleung/pen/gOexjKQ.Hope this gives you some ideas on what you can do, and happy experimenting!
1 - @correlucasPosted over 2 years ago
Hello Anthony Gedeon, congrats for you solution!
I saw that you asked about the media querie for this challenge, but looking you live site I can see that you already fixed it with
flex-direction: column
in addition you can insert on your media query the mobile font-size for h1 is around 24px and for the paragraph is 12px, to have a better behavior with the hero image you can use inside the img on css the properties object-fit: cover; andobject-positon: center;
Keep it up and happy coding, well done!
0
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