Design comparison
Solution retrospective
What common ways people center a div before CSS flexbox exists?
Community feedback
- @NaveenGumastePosted almost 3 years ago
Hay ! Good Job K3mystra
These below mentioned tricks will help you remove any Accessibility Issues
-> Add
Main
tag after body like it should be your container. For 1st heading orh1
tag, use header tag and then inside the header put yourh1
orh2
etc . But use header tag only once in main heading element.-> Use the given
font-size
font-weight
for the title.Keep up the good work!
Marked as helpful1 - Account deleted
Hi there 👋
Congratulate on finishing your project 🎉. The design looks beautiful 😃.
As you asked I will try to answer your question. Before the
flexbox
divs were centered using absolute positioning. It took 3 steps- Make the parent position
relative
- Make the div itself position
absolute
and add top and left 50% - Center back transform translate back
.parent{ position: relative; } .child{ position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
It still helps in some cases where you can't use flex box but can cause some issues also 😉
Happy coding ☕
Marked as helpful1 - Make the parent position
- @denieldenPosted almost 3 years ago
Hi K3mystra, great work :)
Before flexbox it was a real mess ... it was a godsend!
We used to do as @maqsudtolipov said or alternatively we used
margin: auto
... with the defect that it does not center vertically.hope it helps
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