与镀铬物(臭虫)的背景中心 [英] Background center with chrome (bug)
问题描述
我有一个背景图片为中心,Chrome显示偏移一个像素。
I have a background image centered that Chrome displays offset by one pixel.
CSS
#container {
background: url("images/header.jpg") no-repeat scroll 50% transparent;
width: 100%
}
#header {
width: 986px;
margin: 100px auto 0 auto;
}
HTML
<html>
<body>
<div id="container">
<div id="header">centered content</div>
</div>
</body>
</html>
我想这与不同的浏览器如何处理 center
-or
50%
- CSS中的背景
的属性:
I guess it has to do with how different browsers handle the center
-or 50%
- property of the background
in CSS:
>
是否有已知的(简单)骇客或替代方法来解决这个问题?
Is there a known (simple) hack or alternative method to fix this? Background container has to be 100% wide.
推荐答案
对我来说,这样做诀窍:
For me, this did the trick:
@media screen and (-webkit-min-device-pixel-ratio:0) {
html {
margin-left: 1px;
}
}
解决方案,只要我发现我从几天前得到它。
在同一篇文章中,家伙说,问题是容器宽度的奇数或偶数。
无论如何,这解决了我的情况下的问题。
I will post the link for this solution as soon as I find were I got it from a few days ago. In the same post, the guy said the problem was with odd or even number for container width. Anyway, this fixed the problem in my case.
这篇关于与镀铬物(臭虫)的背景中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!