Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Search on google dude. Or use the center tag in html (theoretically deprecated , but works)
-
JaggerJo9408yDone that. Everyone uses creepy hacks.. with translate and so on..
Found a solution that works and isnt hacky
(On the container)
display: flex;
align-items: center; -
JaggerJo9408y
-
SithLord8508yFlexbox finally has great support :-) do that.
Otherwise if you know the height of the h1:
position: absolute
top: 50%
margin-top: -HALF_HEIGHT px -
Seems css is a challenge for a lot of devs. It was not supposed to be this way in the beginning.
-
U should seriously consider using flexbox it will make your life about 1000 times easier
-
quijibo718yDepends exactly where you need to centre it. But if it's one line high and within a div I do love the old: line-height:$heightOfDiv
-
arekxv10528y@JaggerJo There are no "hacks" in CSS, since browser support is still horrible today people use those "hacks" to get stuff done. Flexbox has good support but good support is sometimes not enough. Especially if your client forces IE...
2 hours into css and i still cant figure out how to vertically center this h1 😑🔫
undefined