Hacker News new | ask | show | jobs
by xdennis 1849 days ago
I don't understand why this is downvoted. It doesn't look like top results for "how to center html element" show the flexbox method. My example of "center vertically css" also doesn't show the flexbox method.

The first result recommends the ol' "top:50%; transform:translateY(-50%)". [1]

The second result shows the padding method, the line-height method and the translateY method again. [2]

The third result is a complete guide asking you questions three layers deep about what you want to do and gives you the personalised answer for the scenario. [3]

I gave up afterwards.

But the point is people are still learning old ways of doing it. Should they read a guide to modern CSS? Yes, but we all know searching and clicking on the first result is easier.

[1] https://www.w3schools.com/howto/howto_css_center-vertical.as...

[2] https://www.w3schools.com/css/css_align.asp

[3]: https://css-tricks.com/centering-css-complete-guide/