Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I wonder if there's a good reason for the madness

Well the reason is that CSS originally wasn't intended for layout….

But since there was no other tool for layout, once the web design community decided to remove tables from layout it got drafted despite being severely insufficient. Layout modules have just started being developed, fought upon and implemented in the last few years. Here's how vertical centering looks like when using flexbox (http://philipwalton.github.io/solved-by-flexbox/demos/vertic...):

    .parent {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .centered {
        max-width: 50%;
    }
(note: this ignores prefixing, specs differences and browser-specific issues, here's the component https://github.com/philipwalton/solved-by-flexbox/blob/maste... which is itself expanded to suit browsers)


Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: