Created
April 10, 2010 17:14
-
-
Save paulirish/362170 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery.support.(displayTable|displayTableCell|margin0auto|positionFixed) | |
// jQuery.support.displayTable and displayTableCell - | |
// to determine browser support for setting elements to that css display value | |
$.each(['','-cell'],function(k,v){ | |
$.support['displayTable'+v.replace('-c','C')] = (function(){ | |
var elem = $('<div>',{ | |
css : { | |
display: 'table'+v, | |
position: 'absolute', | |
visibility: 'hidden' | |
} | |
}).appendTo(document.body || document.documentElement), | |
support = ('table'+v) === elem.css('display'); | |
elem.remove(); | |
return support; | |
})(); | |
}) | |
// jQuery.support.margin0auto | |
// to verify that '0 auto' will center things. (ie6 should fail..) | |
$.support.margin0auto = (function(){ | |
var elem = $('<div style="width: 10px; position: relative; "><div style="margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; width: 2px; "></div></div>') | |
.appendTo(document.body || document.documentElement), | |
support = elem.children()[0].offsetLeft === 4; | |
elem.remove(); | |
return support; | |
})(); | |
// jQuery.support.positionFixed | |
// does the browser support `position:fixed` | |
$.support.positionFixed = (function(){ | |
var elem = $('<div>',{ | |
css : { | |
position: 'fixed', | |
top: '42px', | |
visibility: 'hidden' | |
} | |
}).appendTo(document.body || document.documentElement), | |
// also account for page scroll | |
support = parseInt(elem.offset().top,10) - (document.body ? document.body.scrollTop : 0) === 42; | |
elem.remove(); | |
return support; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment