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?
Set the body margin to 0 ...Try this css:
Chrome & firefox rendered differently it's better if you want result same in all browser the always give width in EVEN values not in ODD. So, write like this:
Check this http://jsbin.com/oqisuv/2
UPDATED If you want it's work perfect in chrome the you can use this:
Check this http://jsbin.com/oqisuv/5/
Similar to rudsy's answer, but this one seems to work better:
Most cross-browser and future-proof solution is to attach background to centered block itself (or to its centered parent that has horizontal padding for background to be visible on the outside of its child).
Attempts to achieve pixel-perfect matching of background and block centered independently (especially with hacks for specific browsers) is dead-end road.
Background center with chrome (bug)
http://philfreo.com/blog/fixing-safaris-1px-background-image-centering-problem/