Design comparison
Solution retrospective
Hm, I wonder why my "margin:auto: nor display flex with align-items & justify-content centers didn't work , had to manually use margin-tops to center them..
Flex method only centered the content themselves, even though I targeted the container itself.
Margin:auto, only had targeted left & right, but didn't work for top & bottom. Any ideas?
Thanks!
Community feedback
- Account deleted
Hey Tomatas, You did a great job 😉
Let me give you some little tips:
- add
main
tag and wrap the card for improve the Accessibility - remove all
margin
fromcard
class and use flexbox to the body to center the card. Read here -> flex guide - after, add
min-height: 100vh
to body because Flexbox aligns child items to the size of the parent container - instead of using
px
use relative units of measurement likerem
-> read here
Hope this help! Happy coding 😁 by Travolgi
Marked as helpful1@tomatas95Posted over 2 years ago@travolgi thank you very much! I'll try my best to remember this and use these in my future projects! <3
1Account deleted@tomatas95 You are welcome! Keep it up :)
0 - add
- @wesleyjacobyPosted over 2 years ago
Hi,
To center the card/container, you could add the following to the body:
display: flex; justify-content: center; align-items: center; min-height: 100vh;
The
min-height: 100vh
being the important bit. Then you can remove themargin-top
from the container.This is a great article showing different methods of centering in CSS
I hope this helps!
Marked as helpful1@tomatas95Posted over 2 years ago@wesleyjacoby thank you very much for your offered help, I'll keep in mind in my future projects as well! :)
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