3 ms·
The critical piece I'm always missing is how to center a div vertically if you don't know its height?
by apu 13y ago
The critical piece I'm always missing is how to center a div vertically if you don't know its height?
- igvadaimon 13y agoWell, I'd use display:table-cell with vertical-align:middle.
- platypii 13y agoDoesn't work without the parent having a defined height.
- IvarRafn 13y agoI found this a few days ago, I haven't tried it yet but it looks promising. http://snippetrepo.com/snippets/vertical-align-anything-with-3-lines-of-css http://snippetrepo.com/snippets/vertical-align-anything-with...
- cheapsteak 13y agoDid he make a typo? http://codepen.io/cheapsteak/pen/axJit http://codepen.io/cheapsteak/pen/axJit Doesn't work, unless you change `position: relative` to `position: absolute`
- mbell 13y agoHeres's a trick using pseudo elements : http://codepen.io/anon/pen/pIFna http://codepen.io/anon/pen/pIFna