Skip to content

Instantly share code, notes, and snippets.

@Abban
Created January 9, 2013 15:30
Show Gist options
  • Save Abban/4494035 to your computer and use it in GitHub Desktop.
Save Abban/4494035 to your computer and use it in GitHub Desktop.
Adds Modernizr test for boxsizing then a jQuery element width edit for browsers that don't support it.
/**
* Add Modernizr test for box sizing
*/
Modernizr.addTest("boxsizing", function(){
return Modernizr.testAllProps("boxSizing") && (document.documentMode === undefined || document.documentMode > 7);
});
/**
* Change the width of all elements to account for border-box
*/
$(function(){
if(!($('html').hasClass('boxsizing'))){
$('*').each(function(){
if($(this).css('display')=='block'){
var f, a, n;
f = $(this).outerWidth();
a = $(this).width();
n = a-(f-a);
$(this).css('width', n);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment