日期:2014-05-16  浏览次数:20726 次

使用CSS样式控制显示每张图片会增加40px值,这是为什么?
不多说上源码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>新建网页</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
#container{
width:975px;
}
#header{
height:292px;
background:url(./images/index_01.gif);
}
#nav{
width:975px;

}
#navl{
width:286px;
height:118px;
margin:0px;
float:left;
background: url(./images/index_02.gif);


}
#navm{
width:400px;
height:118px;
margin:0px;
float:left;
background:url(./images/index_03.gif);
}
#navr{
width:289px;
height:118px;
margin:0px;
float:left;
background:url(./images/index_04.gif);
}


</style>
</head>
    <body>
     <div id="container">
      <div id="header"></div>
      <div id="nav">
      <dir id="navl"></dir>
      <dir id="navm"></dir>
      <dir id="navr"></dir>
      </div>
    
      </div>
     </div>
    </body>
</html>

显示结果是每张图片会增加40px值,这是为什么?
经过用FIREFOX 的firebug布局查看发现每张图片的width值要比原图片像素缩小40px值才能正常显示
请教这是属于什么情况?

------解决方案--------------------

#content{
width:975;
}

加上单位px看看是什么情况?区别貌似就是这里和背景图,背景图也应考虑尺寸的排列方式