Design comparison
SolutionDesign
Solution retrospective
Please, how can I center a div element both horizontal and vertical?
Community feedback
- @fidellimPosted about 3 years ago
Hi Solomon,
Greta job finishing the project, to answer your question, you can copy this code:
body { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; }
Hope it helps :)
Marked as helpful1 - @Gabrielbe17Posted about 3 years ago
Hi Solomon, I suggest you to use grid.
- Use
display:grid;
,place-items:center;
to the grid container. In your case, thebody
Tag.
I also suggest you to add
min-height:100vh;
To its container.Marked as helpful0 - Use
- @anar-solPosted about 3 years ago
Hello! You can center an element by adding theses rules to its container
.container { display: flex; justify-content: center; align-items: center; }
To center the element on the screen add this rule to its container
.container { min-height: 100vh; }
Marked as helpful0 - @Mu-SolomonPosted about 3 years ago
Thanks 🤝 for being there guys, I'm really pleased 😌 🙏🏼
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