Skip to content

Instantly share code, notes, and snippets.

@charleslouis
Forked from Abban/Box-Sizing.js
Created April 17, 2013 09:10
Show Gist options
  • Save charleslouis/5402902 to your computer and use it in GitHub Desktop.
Save charleslouis/5402902 to your computer and use it in GitHub Desktop.
/**
* 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