我是那些相信盒子尺寸的人之一:边框盒;是CSS中最好的命令之一,具有所有限制.然而,那些让我想知道是否应该对所有元素应用Box-sizing的限制:
* { -moz-Box-sizing: border-Box; -webkit-Box-sizing: border-Box; -ms-Box-sizing: border-Box; Box-sizing: border-Box; }@H_301_5@当然,我的网站应该与尽可能多的浏览器兼容,当我们考虑IE7时,盒子大小会产生一些问题.但是,有时候时间表太紧,以至于不用担心这个具体问题就能获得额外的几分钟.
无论如何,你认为应用Box-sizing:border-Box;对所有元素都是一个好政策,还是我应该只对实际需要它的元素这样做?
解决方法
保罗谈到以同样的方式使用它
http://paulirish.com/2012/box-sizing-border-box-ftw/
We’ve been using *{Box-sizing: border-Box;} in one of my projects
(deployed in production,averaging over 1mln visits a month) at work
for about a year now,and it seems to be holding up just fine. The
project has been tested in IE8 & 9 and the latests Firefox and Chrome
versions and we’ve had no problems. All jQuery (+UI) offset
calculations and animations run fine,even in any element we’ve
displayed as inline-block. As of late we’ve started testing the
project on mobile devices (iPhone,iPad and Android) and we’ve had no
issues regarding Box-sizing with any of them yet,so it seems to work
just fine.
我发现这有助于解决IE7中的问题