public
Created

Modernizr tests for Absolute Centering ( http://codepen.io/shshaw/pen/gEiDt )

  • Download Gist
Modernizr.AbsoluteCenter.js
JavaScript
1 2 3 4 5 6 7 8
// Will Absolute Centering work in this browser?
Modernizr.testStyles('#modernizr { height: 50px; width: 50px; margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0; }', function(elem, rule) {
Modernizr.addTest('absolutecenter', Math.round(window.innerHeight / 2 - 25) === elem.offsetTop);
});
// Does this browser support Display: Table variable height?
Modernizr.testStyles('#modernizr { display: table; height: 50px; width: 50px; margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0; }', function(elem, rule) {
Modernizr.addTest('absolutecentercontent', Math.round(window.innerHeight / 2 - 25) === elem.offsetTop);
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.