As you can see in [this][1] fiddle, on hover the hover-state of a
always is one pixel higher than the ul. (You can see this in the fiddle: it even gets over the border of ul
) This only happens in Chrome (also tested in FF en IE10, but they don't have that problem). Any solution to that?
Note: 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);
}
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Forum</a></li>
<li><a href="#">About</a></li>
<li class="has-sub-menu"><a href="#">Contact</a></li>
</ul>
</nav>
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
CSS
@media screen and (-webkit-min-device-pixel-ratio:0) {
position:relative;top:-1px;
}
JS
if (navigator.appVersion.indexOf("Chrome/") != -1) {
// modify menu styling
}