Design comparison
SolutionDesign
Solution retrospective
I have used flexbox to center this vertically by setting the height to 100vh, but I am curious if there is a more widely accepted way of doing this? Would love some feedback.
Community feedback
- @danielmrz-devPosted 12 months ago
Hello @cwatso
The technique you used to center your card is one of the most accepted.
Another way to have the same result is apply this to the element you wanna center:
.element { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
I hope it helps!
Marked as helpful1 - @enzo-mirPosted 12 months ago
Hello ! nice challenge ! To avoid the
100vh
on your body try this :html,body {width : 100%; height:100%}; body {display : grid; place-items : center}
And that's it you have a centered container ! Well done ;)
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