Design comparison
SolutionDesign
Solution retrospective
how do i centralize a div alone in the middle of the screen
Community feedback
- @Evavic44Posted over 3 years ago
There are several ways in doing that, all depends on the use case.
div { margin: 0 auto; }
div { position: relative; top: 50%; left: 50%; }
3 Or use a transform property div { transform: translate(50vw, 50vh); }
1@abubakarMana01Posted over 3 years ago@Evavic44 You should also be aware that the div has to have width and height set if you're to use {margin: auto}. The parent container in this case I believe should be the body also needs to have a height so you can centralize vertically as well. Happy coding!!!😁
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