Design comparison
Solution retrospective
I had a good time with this project, but I can't for the life of me get the card centered vertically in desktop. I'd appreciate any pointers! Thank you for taking a look
Community feedback
- @josh76543210Posted about 1 year ago
Hi @bbuglz81,
Congratulations on completing the challenge!
Here is a quick suggestion for centering your card:
First, give your body a minimum height so that your page takes up the entire viewport and display it using flexbox:
body { min-height: 100vh; display: flex; flex-direction: column; }
Next, you can center the card by simply adding a margin of auto all around main:
main { margin: auto; }
Hope this is helpful for you.
Happy Coding!
Marked as helpful1@bbuglz81Posted about 1 year ago@josh76543210 Thank you SO much! I was bashing my head against that one for too long haha
0 - @K01wfdPosted about 1 year ago
Hi @bbuglz81, 1- One way to center your card vertically is to throw min-height 100vh on body selector then display grid, place-content center and that's it. 2- In addition to normalize.css, a simple css reset would make working with content much easier:
*{box-sizing:border-box; margin:0; padding:0;}
, this reset will make sure the content width includes will inculde the padding in the total width calculated by the browser, so you don't have to calculate the content width + padding, and this will reset all the padding and margins to 0.Marked as helpful1
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