我有一个导航菜单,它在psuedo之前,如果我将我的li元素悬停,我想要更改当前li和li之后的属性
.cruise-turlari .cruise-box .cruise-list-box ul li:after {
content: "";
width: 86%;
display: block;
margin: 0 auto;
height: 1px;
background: #cbcbcb;
}
.cruise-turlari .cruise-box .cruise-list-box ul li a {
display: block;
color: #000;
font-size: 14px;
padding: 7px 33px;
-webkit-transition: all linear 0.4s;
-moz-transition: all linear 0.4s;
transition: all linear 0.4s;
}
.cruise-turlari .cruise-box .cruise-list-box ul li a:hover {
background: #000;
color: #FFF;
}
<div class="cruise-list-box">
<ul>
<li><a href="#">Vizesiz Yunan Adaları İzmir Hareket <i class="fa fa-chevron-right"></i></a>
</li>
<li><a href="#">Vizesiz Yunan Adaları İstanbul Hareket <i class="fa fa-chevron-right"></i></a>
</li>
<li><a href="#">Vizesiz Yunan Adaları <i class="fa fa-chevron-right"></i></a>
</li>
<li><a href="#">Ege & Adriyatik <i class="fa fa-chevron-right"></i></a>
</li>
<li><a href="#">Akdeniz & Adriyatik <i class="fa fa-chevron-right"></i></a>
</li>
<li><a href="#">Baltık Başkentleri <i class="fa fa-chevron-right"></i></a>
</li>
<li><a href="#">Kuzey Avrupa & Akdeniz <i class="fa fa-chevron-right"></i></a>
</li>
<li><a href="#">Fiyordlar <i class="fa fa-chevron-right"></i></a>
</li>
<li><a href="#">Akdeniz <i class="fa fa-chevron-right"></i></a>
</li>
<li><a href="#">Kanarya Adaları <i class="fa fa-chevron-right"></i></a>
</li>
</ul>
</div>
答案 0 :(得分:2)
我认为这就是你想要的:
.cruise-turlari .cruise-box .cruise-list-box ul li:hover:before, .cruise-turlari .cruise-box .cruise-list-box ul li:hover + li:before {
height: 1px;
background: transparent;
}
所以你也可以在悬停上使用相邻的兄弟选择器。
答案 1 :(得分:0)
你添加一个特殊的类
.cruise-list-box ul li.special:after {
height: 1px;
opacity: 0;
}
然后,使用jQuery,在mouseover和mouseleave上添加事件
$('li').mouseover(function(){
$(this).addClass('special');
});
$('li').mouseleave(function(){
$(this).removeClass('special');
});