Re:The complete guide to centering a div
by apu on Sunday February 02, 2014 @03:58PM
(#7167555)
The critical piece I'm always missing is how to center a div vertically if you don't know its height?
[ Parent
| on HN ]
Re:The complete guide to centering a div
by igvadaimon on Sunday February 02, 2014 @04:02PM
(#7167567)
Well, I'd use display:table-cell with vertical-align:middle.
Re:The complete guide to centering a div
by platypii on Sunday February 02, 2014 @06:32PM
(#7168089)
Doesn't work without the parent having a defined height.
Re:The complete guide to centering a div
by IvarRafn on Sunday February 02, 2014 @04:15PM
(#7167619)
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...
Re:The complete guide to centering a div
by cheapsteak on Sunday February 02, 2014 @04:38PM
(#7167695)
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