Single Price Grid Component

Solution retrospective
I think the result is ok, but... How can I center both horizontal and vertical an element (div for example) the most optimal way? (If possible without using flex, grid or position)
Anyway, any feedback, comment or question is welcome :)
Please log in to post a comment
Log in with GitHubCommunity feedback
- @vanzasetia
Hey, Canti! 👋
Congratulations on finishing this challenge! 🎉
You have an interesting question. I never thought about how to center a div without using flexbox, grid, and
position
property. So, I did some research and it turned out that it is possible. You can usedisplay: table
to do it. But, keep in mind that I have never tried doing this so I am not sure it will work well. (reference: https://www.tutorialstonight.com/how-to-center-a-div-in-css#using-display-table-cell-v)But, I would recommend using either flexbox or grid. It's a more robust solution to center the card and also both have good support.
So, there is no reason to not use flexbox or grid. 🙂
Taking a look at your solution, you use flexbox to center the card. However, I would prefer making the
body
element as the flex container and then making themain
element as grid container.You can set the
flex-direction
tocolumn
to make the attribution below the card. For themain
element, you can usegrid-template-column
to control the layout of the card.That's it! I hope you find this useful! 😊
- @HatimHJ
This comment was deleted almost 3 years ago
Join 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