两年前我写了一个设计:目标是适应 1024 像素的屏幕,但有一些额外的图形内容,这样在大屏幕上就不会显得太小。结果是http://megalest.org/,一个开源项目的网站。
这是 HTML:我不想使用 img 标签,因为它可以让我在不会加载此类图像的响应式设计中工作:
<div id='all'>
<div id="header">
<div id="header_left"></div>
</div>
</div>
这是相应的CSS:
#all {
width: 1016px;
margin: 0 auto;
}
#header {
height: 313px;
background-color: #4dd;
}
#header_left {
float: left;
width: 140px;
margin-left: -140px;
height: 379px;
/* works fine */
/* background: #dd4; */
/* there's a one pixel offet */
background:
url("http://megaglest.org/uploads/megaglest2011/header/left.jpg")
no-repeat;
}
仅在 Google Chrome(Linux 上为 22.0.1229.94)上,并且仅在某些窗口大小下(当只有 #header_left 的一部分可见时),我在图像和蓝色标题之间得到一个像素的偏移量。当“结果窗格”非常宽时,可以看到使用这个 jsFiddle:http: //jsfiddle.net/hTbJA/
这是该问题的屏幕截图。奇怪的是,Google Chrome 开发者工具在“metrics”中说 div 是 140px 宽,但是当我使用“Elements”窗格并悬停#header_left 时,它却显示为 141px!会不会是浏览器的bug?
谢谢。