Design comparison
SolutionDesign
Solution retrospective
Can anyone help me with how to Vertical Align the div?
Community feedback
- @CharlieCastleWebPosted over 2 years ago
Hi Arun ! Great work, anyway!
The solution I use to center the main content is:
- Give both the html and body a height of 100%
- On the body selector apply display: flex, align-items:center, justify-content: center
- Then in order to leave the footer at the bottom you'll need to apply margin-top: auto to both the main and footer selectors.
Hope this works, let me know if you need more help
Marked as helpful0 - @BaraditPosted over 2 years ago
Nice solution buddy! To center the div, you can use this code into your body: height: 100vh; display: grid; place-content: center; Keep it going!
Marked as helpful0 - @Dev-TronPosted over 2 years ago
There are many ways to center a div. In your case you could try giving your body a margin-top value of maybe 10% or so.
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