by _bxg1 · 6y ago · 0 comments
Today you can simply use flexbox on the container:
display: flex;
justify-content: center; // horizontal
align-items: center; // vertical
Doesn't work in IE without a JS polyfill (which is available), but has worked in all other browsers for six years or so.> Centering in CSS is a pain in the ass. There seems to be a gazillion ways to do it, depending on a variety of factors.
Which is no longer true in the great majority of cases.
Also, this site seems to have gone up in 2015 and hasn't changed (substantially) since.
I also don't think you're correct in calling this a straw man. This is not a debate and there was no other party whose assertion this site seems to refute, so calling it a straw man doesn't seem to fit.
This works in IE without a JavaScript polyfill (lol): <html> <body> <div style="width: 400px; height: 400px; background: red; display: flex; align-items: center; justify-content: center;"> <div>TESTING</div> </div> </body> </html>