Design comparison
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 :)
Community feedback
- @vanzasetiaPosted over 2 years ago
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! 😊
1 - @HatimHJPosted over 2 years ago
This comment was deleted over 2 years ago
0@vanzasetiaPosted over 2 years ago@HatimHJ
For the Markdown syntax for the link, you want to use the square brackets to wrap the text content and then wrap the URL with brackets.
[example](https://www.example.com/)
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