Reputation: 425
I try to create an effect on my menu.
I try to add a 3px border on the top of each "li" in my menu. I would like that it's border appears on hover. But I didn't manage to.
I try with :after but nothing change.
#mm {
width: 960px;
height: 50px;
background-color: #e8e4e0;
}
#mm ul li {
display: inline-block;
width: 160px;
height: 50px;
}
#mm ul li a {
text-transform: uppercase;
color: #372f7e;
font-size: 9.2px;
line-height: 50px;
text-align: center;
}
#mm ul li:hover {
content: '';
position: relative;
background-color: #ffffff;
font-weight: bold;
border-top: 4px solid black;
line-height: 46px;
}
<div id="mm">
<ul>
<li><a href="">Choice</a></li>
<li><a href="">Choice</a></li>
<li><a href="">Choice</a></li>
<li><a href="">Choice</a></li>
<li><a href="">Choice</a></li>
<li><a href="">Choice</a></li>
</ul>
</div>
Upvotes: 2
Views: 48
Reputation: 3398
I think your code is almost OK. It works but it looks terrible. It's better to have border-top
with transparent color and then change it on hover:
#mm ul li {
border-top: 4px solid transparent;
}
#mm ul li:hover {
border-top-color: black;
}
Here's the example http://jsfiddle.net/infous/abmhtL4x/
Upvotes: 1