Design comparison
SolutionDesign
Solution retrospective
give your feedback
Community feedback
- @Ambe-Mbong-NwiPosted almost 2 years ago
Nice job. To centralize your design on a page both vertically and horizontally, use
body{ margin: 0 auto; }
Alternatively, centering the element with position would make your element behave strangely on some mobile devices, "there's a chance the content will grow to overflow the parent". You can use flexbox or grid layout to center elements. You can read more about centering in CSS here: Using flexbox:
body { min-height: 100vh; display: flex; justify-content: center; align-items: center; }
Using grid:
body { min-height: 100vh; display: grid; place-content: center; }
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