Skip to content

Instantly share code, notes, and snippets.

@shshaw
Created August 23, 2013 21:20
Show Gist options
  • Save shshaw/6324153 to your computer and use it in GitHub Desktop.
Save shshaw/6324153 to your computer and use it in GitHub Desktop.
Modernizr tests for Absolute Centering ( http://codepen.io/shshaw/pen/gEiDt )
// 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);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment