Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix 1px margin on Google Chrome?

Here an example 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>

If you view an example above on Google Chrome you will see the .menu looks like have a margin-left:-1px or margin-right:1px.

On Firefox & IE it's look great. How do I fix this one?

like image 896
Unknown Error Avatar asked Mar 17 '12 17:03

Unknown Error


2 Answers

@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/

like image 119
huhu Avatar answered Sep 22 '22 17:09

huhu


Similar to rudsy's answer, but this one seems to work better:

@media screen and (-webkit-min-device-pixel-ratio:0) {
    body {
        background-position: 49.999% 0;
    }
}
like image 44
Robert Pessagno Avatar answered Sep 19 '22 17:09

Robert Pessagno