Design comparison
SolutionDesign
Community feedback
- @RealKendprPosted 10 months ago
I checked your code on github and I see that you used
margin: auto;
to center your.container
horizontally, but based on the design you still have to center it vertically.To do that you can use one of the following: First remove the auto margin then proceed
- Absolute positioning
You can add this code inside your
.container
:position: absolute; top: 50%; left: 50%; transfrom: translate(-50%,-50%);
- Centering it with grid
or do this instead:
Make the parent element of your
.container
(which in your case isbody
) a grid:body {display: grid; place-items: center;}
Just take note that by using this every sibling of your.container
will also be centered, so they might be covered by the other sibling
It should center it both horizontally and vertically
Marked as helpful0@santosdlaysaPosted 10 months agoThank you for your help, it was very useful. @RealKendpr
0 - Absolute positioning
You can add this code inside your
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