I have a menu where I am using the :after element. When I hover over a li in the menu, the hover effect also includes the :after element.
HTML:
<ul class="main-menu">
<li class="active"><a href="">Menu</a></li>
<li><a href="">Menu</a></li>
<li><a href="">Menu</a></li>
<li><a href="">Menu</a></li>
<li><a href="">Menu</a></li>
<li><a href="">Menu</a></li>
<li><a href="">Menu</a></li>
</ul>
CSS:
/* MAIN MENU */
.main-menu {
list-style-type: none;
padding: 0;
margin: 0;
background: url("../img/li.png") repeat-x; height: 56px;
}
.main-menu li {
display: inline-block;
color: #fff;
height: 56px;
background: url("../img/li.png") repeat-x; height: 56px;
line-height: 56px;
}
.main-menu li:after {
content: "|";
}
.main-menu li:last-child:after {
content: "";
}
.main-menu li:hover {
background: url("../img/li-hover.png") repeat-x; height: 56px;
}
.main-menu .active {
background: url("../img/li-hover.png") repeat-x; height: 56px;
}
.main-menu li a {
text-decoration: none;
color: #d2eff3;
padding: 10px;
}
.main-menu li a:hover {
}
JsFiddle:
Check out the JsFiddle example here
Question:
How can I prevent the li:after
element from being affected by the hover effect?
(When hovering over the menu, the hover effect extends to the "|" separator. I want to disable the hover effect under the separator)
I have tried:
.main-menu li:after:hover {
background: none;
}
But it didn't work as expected.
Thank you for your assistance!