Responsive card using HTML and CSS
Design comparison
Community feedback
- @correlucasPosted about 2 years ago
πΎHello @etherubn, Congratulations on completing this challenge!
Your solution its almost done and Iβve some tips to help you to improve it:
Fix the alignment of the whole content using
flex
andmin-height
to manage the vertical alignment and make everything centered.First of all putmin-height: 100vh
to thebody
to make the body display 100% of the viewport height (this makes the container align to the height size that's now 100% of the screen height) size anddisplay: flex
eflex-direction: column
to align the child element (the container) vertically using the body as reference.body { min-height: 100vh; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
π¨βπ»Here's my solution for this challenge if you wants to see how I build it: https://www.frontendmentor.io/solutions/product-preview-card-vanilla-css-and-custom-hover-state-on-hero-85A1JsueD1
βοΈ I hope this helps you and happy coding!
Marked as helpful1@etherubnPosted about 2 years agoI don't understand why I need to do that to the body, I think that the only element how need to be responsive is the card. Can you explain me, please ?
0 - @Nasir222222Posted about 2 years ago
can u try centering it with
margin: 0 auto;
or with flexbox
display: flex; flex-direction: column; align-items: center; justify-content: center;
1 - @denieldenPosted about 2 years ago
Hello Ruben, You have done a good work! π
Some little tips to improve your code:
- add
main
tag and wrap the card for improve the Accessibility - use flexbox to the body to center the card. Read here -> best flex guide
- after, add
min-height: 100vh
to body because Flexbox aligns child items to the size of the parent container
Keep learning how to code with your amazing solutions to challenges.
Hope this help π and Happy coding!
0 - add
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