html - 如何在 Google Chrome 上修复 1px 边距?

标签 html css google-chrome

这里有一个例子 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:-1pxmargin-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/

相关文章:

html - 两个元素之间的黑色 1px 线

html - 正文内容 div 展开以在保持页脚的同时填满屏幕

css - 集成到 Symfony 2 中时,如何从 LESS 编译器中获得好的错误

javascript - 在 tabs.executeScript 回调中使用时 browserAction.setBadgeText 不会被执行

javascript - 无法在音频播放器中添加音乐文件

php - 如何使用 PHP 比较两个表并返回不匹配的结果

javascript - 是否可以在 html 文本字段中显示图像?

html - 一些@media 规则不遵守

CSS: mix-blend-mode = color-dodge 在 Chrome 中不起作用,但在 Firefox 中正常

javascript - 如何使用 Javascript 在 Chrome 中检测选项卡何时聚焦或不聚焦?