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

For vertical centering, I never understood why you couldn't just give the container a fixed size and then, on the element, set margin-top and margin-bottom to auto. It works like this for horizontal centering.

My guess is that the specification treats vertical margins in a weird way. For example, margin-top:50% means 50% of the width, not of the height. I don't know why they decided to do it like that.



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

Search: