Design comparison
Solution retrospective
I used a CSS grid to center the element. Is there another way to center the element? And I can use flexbox to center the element.
Community feedback
- @afaiz-spacePosted over 2 years ago
Hey @MabIggo
- use flex or grid property for object center.
- change the background color
- read the style guide file
Marked as helpful1 - Account deleted
Hi MabIggo! Congrats on finishing your first challenge 💪
Yes, you can center a element with flexbox as well. Here's how you do it:
First you need to set a height on a container element. The best option is to set
height: 100vh;
Then you go and add
display: flex;
declaration.Next you need to center the item both vertically and horizontally. You should add these two declarations:
align-items: center;
justify-content: center;
And that's it, now you have centered the flex item inside the container element.
I hope this was helpful. Happy coding! 👨💻
Marked as helpful1
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