Design comparison
Solution retrospective
I couldn't get my card to justify center, so I added a margin-top to remedy this. What is the cause of that happening? And is there a better solution? I wasn't sure to remove the space on the sides of the image without it affecting the border radius, is there a solution for this?
Community feedback
- @Toluwaa-oPosted almost 2 years ago
Concerning your question, this should work:
body { max-width: 100vw; min-height: 100vh; display: grid; place-content: center; }
Max-width specifies the maximum width of the page and 100vw is a relative unit so it adapts to each device. Likewise min-height. It specifies the minimum width of the page. Setting it to 100vh means it will always take up the whole screen. VW means view width and VH means view height. For more info https://www.w3schools.com/cssref/css_units.php
You don't have to use the display grid/place content i used. But i suggested it because it takes less time to write and it has the same effect as using both justify-content & align items.
And lastly, I'd recommend adding padding to the container instead of adding it to each individual element in the container, that way they all align properly.
I hope these suggestions are helpful, let me know if you have any other question.
Marked as helpful1 - @ferlaxiPosted almost 2 years ago
the container was not centered because a height value was not defined. You should put in the css file in body: height: 100vh; and remove the margin-top and voila! :) nice work! it looks really nice
2
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