在给元素设置background-color时,IE8-作用区域是content+padding,而IE8+(包括IE8)、火狐、谷歌则是content+padding+border。举个栗子:

  

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
       #outerBox{
        width: 128px;
        height: 128px;
        border: 10px black dashed;
        background-color: silver;
       }
    </style>
</head>
<body>
    <div id="outerBox"></div>  
</body>
</html>

上述代码在各浏览器下效果:

IE8+:

IE8-:

chrome:

Firefox:

posted on 2015-07-01 09:33  -大灰羊-  阅读(148)  评论(0)    收藏  举报