4 ms·
Then unfortunately you have to calculate it with JS if it varies. Vertically centering divs has always been a gigantic pain-in-the-ass. If anyone has a better i
by Mandatum 13y ago
Then unfortunately you have to calculate it with JS if it varies. Vertically centering divs has always been a gigantic pain-in-the-ass. If anyone has a better idea for doing this without JS, please let me know. Once CSS implements variable-based elements (ie #div.height) then we'll have a lot more control.
- markdown 13y ago> If anyone has a better idea for doing this without JS, please let me know. Flexbox, with optional fallback to JS for IE 8 and 9. That said, vertical centering is almost always a nice-to-have rather than a must-have so personally I wouldn't even use a fallback. http://philipwalton.github.io/solved-by-flexbox/demos/vertical-centering/ http://philipwalton.github.io/solved-by-flexbox/demos/vertic... http://caniuse.com/flexbox http://caniuse.com/flexbox
- deleted 13y ago[deleted]
- lobster_johnson 13y agoAs mentioned elsewhere: "display: table-cell" with "vertical-align: middle".