有点烦人的问题,我在我的智囊团结束,所以寻找一些帮助。
我已经为导航制作了一个代码笔-http://codepen.io/nickelse/pen/yNwPwv
当你将鼠标悬停在一个导航链接上时,它会覆盖左边的分隔符,但显示右边的分隔符,有人对我如何让链接悬停覆盖两边的分隔符或坐在中间有什么建议吗?
干杯,
尼克

<div class="navigation cf">
  <div class="menu cf">
    <ul>
      <li><a href="#">Poker Chips</a></li>
      <li>
        <a href="#">Poker Chip Sets<i class="fa fa-caret-down"></i></a>
        <ul class="sub-menu">
          <li><a href="#">Sub Link 1</a></li>
          <li><a href="#">Sub Link 2</a></li>
          <li><a href="#">Sub Link 3</a></li>
          <li><a href="#">Sub Link 4</a></li>
        </ul>
      </li>
      <li><a href="#">Poker Tables</a></li>
      <li><a href="#">Poker Chip Cases</a></li>
      <li><a href="#">Poker Playing Cards</a></li>
      <li><a href="#">Poker Accessories</a></li>
    </ul>
  </div>
</div>


body {
  background: #272727;
}

/*----- Menu Outline -----*/
.navigation {
  width: 100%;
  background: #454545;
  border-bottom: 3px solid #666;
}

.menu {
  width: 1000px;
  margin: 0px auto;
  text-align: center;
  font-size: 0;
}

.menu li {
  margin: 0px;
}

.menu a {
  transition: all linear 0.15s;
  color: #fff;
}

.menu li:hover > a {
  text-decoration: none;
  color: #ddd;
}

.menu .arrow {
  font-size: 11px;
  line-height: 0%;
}

/*----- Top Level -----*/
.menu > ul {
  margin: 0;
  padding: 0;
}

.menu > ul > li {
  display: inline-block;
  position: relative;
  font-size: 14px;
  background: url(http://i.imgur.com/ijNENpN.png) no-repeat left 50%;
}

.menu > ul > li:first-child {
  background: none;
}

.menu > ul > li > a {
  padding: 20px 24px;
  display: block;
}

.menu > ul > li:hover > a{
  background: #666;
}

/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
  z-index: 1;
  opacity: 1;
}

.sub-menu {
  width: 280px;
  padding: 0;
  position: absolute;
  top: 100%;
  left: 0px;
  z-index: -1;
  opacity: 0;
  transition: opacity linear 0.2s;
  background: #666;
  text-align: left;
}

.sub-menu li {
  display: block;
  font-size: 14px;
}

.sub-menu li a {
  padding: 10px 24px;
  display: block;
  color: #fff;
}

.sub-menu li a:hover {
  background: #353535;
}

.navigation .fa.fa-caret-down   {
    margin-left: 6px;
}


.cf:before,
.cf:after {
  content: " "; /* 1 */
  display: table; /* 2 */
}

.cf:after {
  clear: both;
}

/** For IE 6/7 only - Include this rule to trigger hasLayout and contain floats. */
.cf {
  *zoom: 1;
}

最佳答案

分隔符实际上与被悬停的分隔符旁边的li相关联,因此快速解决方法是将其隐藏,以便:

.menu li:hover + li {
  background-image: none;
}

Codepen Demo

关于html - 导航栏上的分频器问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31919126/

10-09 13:57