这里有一个例子 http://jsbin.com/oqisuv/
CSS
body {
background:#e7ebf2 url(http://i.imgur.com/R2VB6.png) center repeat-y;
}
.menu {
width:989px;
margin:auto;
height:100px;
background:#666666;
line-height:100px;
text-align:center;
color:#fff;
}
HTML
<body>
<div class="menu">Hello</div>
</body>
如果您在 Google Chrome 上查看上面的示例,您会看到 .menu
看起来有一个 margin-left:-1px
或 margin-right: 1px
。
在 Firefox 和 IE 上它看起来很棒。我该如何解决这个问题?
最佳答案
@media screen and (-webkit-min-device-pixel-ratio:0) {
html {
margin-left: 1px;
}
}
Background center with chrome (bug)
body {
background:#e7ebf2 url(http://i.imgur.com/R2VB6.png) 50% 0 repeat-y;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
body {
background-position: 50.001% 0;
}
}
http://philfreo.com/blog/fixing-safaris-1px-background-image-centering-problem/
关于html - 如何在 Google Chrome 上修复 1px 边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9752201/