├── README.markdown ├── borderBoxModel-min.js └── borderBoxModel.js /README.markdown: -------------------------------------------------------------------------------- 1 | # Border-box model support for Internet Explorer 6-7 2 | 3 | One of the new, shiny CSS3 proprieties that you can start using today is `box-sizing`. 4 | This propriety allows you to switch between box models. 5 | 6 | As of today, the browser support is really wide and this propriety works on: 7 | 8 | - Firefox 1+ (with the `-moz` prefix) 9 | - Safari 3+ (with the `-webkit` prefix) 10 | - Opera 8.5+ 11 | - Internet Explorer 8+ 12 | 13 | This script will enable the `border-box` model also in IE6 and IE7 without trigger the *Quirks Mode*. 14 | 15 | # Basic usage 16 | 17 | The function has no dependency, just put the minified version of the script at the bottom of the page, before the ``, so it will be lauched as soon as possible. 18 | To be sure that it is executed only if the version of IE is prior to 8, use the conditional comments: 19 | 20 | 25 | 26 | # Known issues and limitations 27 | 28 | - Currently it works only if padding and border are set in `px`. 29 | - Width and height are written inline, so no fluid behaviour (es. onresize, min/max-width,...) 30 | - Probably it needs more tests with complex layouts (with negative margins, ...) 31 | 32 | # More info 33 | 34 | Read my article about the [CSS3 box-sizing propriety](http://albertogasparin.it/) 35 | -------------------------------------------------------------------------------- /borderBoxModel-min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Add support fo CSS3 box-sizing: border-box model for IE6 and IE7 3 | * 4 | * @author Alberto Gasparin http://albertogasparin.it/ 5 | * @version 1.1, License MIT 6 | * 7 | **/ 8 | 9 | var borderBoxModel=function(l,d){function m(){e=parseInt(b.width,10)||parseInt(a.width,10);f=parseInt(b.height,10)||parseInt(a.height,10);if(e){var c=parseInt(b.borderLeftWidth||a.borderLeftWidth,10)||0,g=parseInt(b.borderRightWidth||a.borderRightWidth,10)||0,h=parseInt(b.paddingLeft||a.paddingLeft,10),i=parseInt(b.paddingRight||a.paddingRight,10);if(c=c+h+i+g)a.width=e-c}if(f){c=parseInt(b.borderTopWidth||a.borderTopWidth,10)||0;g=parseInt(b.borderBottomWidth||a.borderBottomWidth,10)||0;h=parseInt(b.paddingTop||a.paddingTop,10);i=parseInt(b.paddingBottom||a.paddingBottom,10);if(c=c+h+i+g)a.height=f-c}}for(var j,b,a,e,f,k=0,n=l.length;k