Design comparison
Solution retrospective
I've always had this question: How do I center an element correctly? I would really appreciate if anyone could give me advice on the best way to do this.
Community feedback
- @DhahiraThesneemPosted 9 months ago
Hi @Roshan-moger!
Your design is pretty good. It will be better if you use some flex-container wrap around the flex items instead of body.
And, you can look this article, it widely cover how to center a div in different aspects.
Hope it will help you!
Marked as helpful1 - @Roshan-mogerPosted 9 months ago
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: hsl(212, 45%, 89%) }
0@YohannesDreamPosted 9 months agoIn order to align items vertically use: flex-direction: column; @Roshan-moger
0@IzykGitPosted 9 months agoYou can use there backticks to turn your comment into a code block. Place three backticks before and after your piece of code to make it look like this.
body: { display: flex; justify-content: center; align-content: center; min-height: 100vh; }
You can also click on markdown help for more. @Roshan-moger
0
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