-1

正如您在 [this][1] fiddle 中看到的,在悬停时,悬停状态a总是比 ul 高一个像素。(您可以在小提琴中看到这一点:它甚至超出了 的边界ul)这只发生在 Chrome 中(也在 FF en IE10 中测试过,但他们没有这个问题)。有什么解决办法吗?

注意:overflow: hidden不是解决方案,因为我希望溢出对其他内容(子菜单等)可见。

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>

4

1 回答 1

-1

如果您的菜单在 Chrome 中低 1 个像素;有两种特定于浏览器的方法只能在 Chrome 中应用校正样式。查看已回答的类似帖子

CSS

@media screen and (-webkit-min-device-pixel-ratio:0) { 
  position:relative;top:-1px;
}

JS

if (navigator.appVersion.indexOf("Chrome/") != -1) {
  // modify menu styling 
}
于 2013-01-11T19:37:15.807 回答