Design comparison
Solution retrospective
Recommendations for tidying up the CSS. A better way to center the container. Any other advice welcome
Community feedback
- @sgarcialagunaPosted over 1 year ago
Easiest way to center:
.container { display: grid; place-items: center; }
Then remove all the stuff with absolute positioning, negative margins etc.
You can also use
100vh
to have your container use the available viewport height. If you get a scrollbar, it's because default browser styles add a margin on the body. Explicitly remove it withbody { margin: 0 }
. There is some nuance to 100vh, see Kevin Powell, but it is better than using pixel values.As a general matter, try to avoid setting fixed "magic" pixel widths and height on your card / container. Instead, let the content define the card sizes.
Marked as helpful0
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