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

The critical piece I'm always missing is how to center a div vertically if you don't know its height?


Well, I'd use display:table-cell with vertical-align:middle.


Doesn't work without the parent having a defined height.


I found this a few days ago, I haven't tried it yet but it looks promising. http://snippetrepo.com/snippets/vertical-align-anything-with...


Did he make a typo?

http://codepen.io/cheapsteak/pen/axJit

Doesn't work, unless you change `position: relative` to `position: absolute`


Heres's a trick using pseudo elements : http://codepen.io/anon/pen/pIFna




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

Search: