پیشنمایش زنده
کد HTML
<button>
<a id="bot" href="#"> Hover Over </a>
</button>
کد CSS
button {
font-size: 18px;
color: #e1e1e1;
font-family: inherit;
font-weight: 800;
cursor: pointer;
position: relative;
border: none;
background: none;
text-transform: uppercase;
transition-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1);
transition-duration: 400ms;
transition-property: color;
}
a {
color: white;
text-decoration: none;
}
button:focus,
button:hover {
color: #fff;
}
button:focus:after,
button:hover:after {
width: 50%;
left: 0%;
}
button:after {
content: "";
pointer-events: none;
bottom: 25px;
left: 50%;
position: absolute;
width: 0%;
height: 2px;
background-color: #fff;
transition-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1);
transition-duration: 400ms;
transition-property: width, left;
}
#bot:focus,
#bot:hover {
color: #fff;
}
#bot:focus:after,
#bot:hover:after {
width: 50%;
right: 0%;
}
#bot:after {
content: "";
pointer-events: none;
bottom: -5px;
left: 50%;
position: absolute;
width: 0%;
height: 2px;
background-color: #fff;
transition-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1);
transition-duration: 400ms;
transition-property: width, right;
}