Snippet berikut efek menu on hover yang simple dan clean dengan menganimasikan border.
<ul> <li><a href="#">home</a></li> <li><a href="#">about</a></li> <li><a href="#">services</a></li> </ul>
body {
margin: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
font-family: verdana
}
ul {
padding: 0;
display: flex;
}
li {
list-style-type: none;
padding: 10px 20px;
}
a {
text-decoration: none;
text-transform: uppercase;
font-size: 20px;
color: #222;
position: relative;
}
ul li a:before {
content: "";
width: 0;
height: 5px;
background-color: #00bcd4;
position: absolute;
top: 120%;
left: 0;
transition: all 0.5s;
}
ul li a:after {
content: "";
width: 0;
height: 5px;
background-color: #f0f;
position: absolute;
top: 120%;
right: 0;
transition: all 0.5s;
}
ul li a:hover:before {
width: 50%;
transform: translateX(100%);
}
ul li a:hover:after {
width: 50%;
transform: translateX(-100%);
}