Design comparison
Solution retrospective
What can I do to center the comonent the right way?
Community feedback
- @HassiaiPosted almost 2 years ago
There is no need to give the body a width value and a max-width value in the body.
Give .main a background-color of white, a max-width value instead of a width value. for more a responsive width. There is no need to give .main a height value.
Use rem or em as unit for the padding, margin, width and preferably rem for the font-size for more on this watch this https://youtu.be/N5wpD9Ov_To
Hope am helpful. HAPPY CODING
Marked as helpful1 - @sjannnPosted almost 2 years ago
Hey friend👋, I recommend you take a look at this article, it was very useful for me to learn different ways when it comes to learning to center elements.
https://www.freecodecamp.org/news/how-to-center-a-div-with-css-10-different-ways/
You can review my solutions and leave me feedback, it is always very grateful.
Happy Code!!🚀
Marked as helpful1 - @DavidMorgadePosted almost 2 years ago
Hello Daniel, congrats on finishing the challenge!
You are doing good using
display: grid
place-items: center
on your parent component, the problem is that setting amax-width: 1440px
on your body will limit the width of the component, not getting centered, you should remove hardcode widths on your body.Apart from that you could also use
display: flex
justify-content: center
align-items: center
to center your component from the parent element.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