7 ms·
Can anyone explain the bit about 1x1.gif being the only way, to this day, to vertically center elements? AFAIK there's still no way to vertically center a dynam
by powrtoch 13y ago
Can anyone explain the bit about 1x1.gif being the only way, to this day, to vertically center elements? AFAIK there's still no way to vertically center a dynamic height element without javascript, so if invisible gifs can do it I'd at least like to know how.
- wycats 13y agoYou can use CSS flexbox too :)
- eliot_sykes 13y agohttp://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/ http://zerosixthree.se/vertical-align-anything-with-just-3-l...
- dabeeeenster 13y agoIt was used more to stretch table cells to achieve pixel perfect layouts.
- Zarel 13y agoI don't know about spacer gifs, but you can use tables. Or fake tables using CSS. JavaScript definitely isn't required, even to vertically center things in IE6.
- 0x0 13y agoA little mix of display:table and display:table-cell and vertical-align:middle will get you there without any JS. For example http://css-tricks.com/centering-in-the-unknown/ http://css-tricks.com/centering-in-the-unknown/
- dalke 13y agoIt's pseudo-centered, not really centered, and can't center a dynamic element.
- panzi 13y agoThis even works in IE8: http://jsfiddle.net/QVQLN/ http://jsfiddle.net/QVQLN/ jsfiddle itself doesn't work in IE8, so hier is a direct link: http://fiddle.jshell.net/QVQLN/show/ http://fiddle.jshell.net/QVQLN/show/
- mietek 13y agoFlexbox has mostly landed: http://philipwalton.github.io/solved-by-flexbox/demos/vertical-centering/ http://philipwalton.github.io/solved-by-flexbox/demos/vertic...
- Kluny 13y agoI don't know that it works in every use case, but I usually use a container with equal left and right margins.
- panzi 13y agopowrtoch was talking about vertically centering.