Menu with Sliding Selector on Hover
Made for some guy on reddit, not very elegant but it functions just fine once you set it up...
by Roberto Apasajja
HTML
<div class='menu-top'>
<div class='menu-item a'>Home</div>
<div class='menu-item b'>About</div>
<div class='menu-item c'>News</div>
<div class='menu-item d'>Why?</div>
<div class='menu-bot'>
<div class='menu-bar'></div>
</div>
</div>
CSS
.menu-top {
display: inline-block;
}
.menu-item {
display: inline-block;
background: lightBlue;
margin: 0px;
padding: 2px 8px;
cursor: pointer;
}
.menu-bot {
width: 100%;
height: 4px;
background: navy;
margin-top: 2px;
position: relative;
}
.menu-bar {
position: absolute;
height: 100%;
left: 0;
width: 55px;
background: orange;
-webkit-transition: 0.4s;
}
.menu-item.a:hover ~ .menu-bot .menu-bar {
width: 55px;
left: 0;
}
.menu-item.b:hover ~ .menu-bot .menu-bar {
width: 56px;
left: 59px;
}
.menu-item.c:hover ~ .menu-bot .menu-bar {
width: 53px;
left: 119px;
}
.menu-item.d:hover ~ .menu-bot .menu-bar {
width: 54px;
left: 176px;
}