Bram Vanroy Bram Vanroy - 1 year ago 92
CSS Question

Chrome not being pixel perfect when a is display: block

As you can see in this fiddle, on hover the hover-state of

always is one pixel higher than the ul. (You can see this in the fiddle: it even gets over the border of
) This only happens in Chrome (also tested in FF en IE10, but they don't have that problem). Any solution to that?

overflow: hidden
is not a solution, because I want overflow to be visible for other stuff (sub-menus among others).


ul {
list-style: none;
text-align: center;
background: whiteSmoke;
border: 1px solid red;

li {
display: inline-block;
font-size: 150%;
position: relative;
margin: 0;

li a {
color: #555;
text-decoration: none;
text-shadow: 0 2px 0 white;
display: block;
padding: 0.2em 0.5em 0.3em;

li a:hover {
color: black;
background: whiteSmoke;
box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.125);

Answer Source

If your menu is one pixel low in Chrome; there are two browser-specifc approaches that could apply correctional styling only in Chrome. See Similar Post Answered


@media screen and (-webkit-min-device-pixel-ratio:0) { 


if (navigator.appVersion.indexOf("Chrome/") != -1) {
  // modify menu styling 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download