I have the following code:
.link {
font-family: 'Arial';
text-transform: Uppercase;
color: #000;
text-decoration: none;
display: inline-block;
}
.link:after {
content: "";
display: block;
padding-top: 3px;
border-bottom: 2px solid black;
transform: scaleX(1);
transition: transform 250ms ease-in-out;
transform-origin: 0% 50%
}
.link:hover:after {
transform: scaleX(0);
transform-origin: 100% 50%;
}
<a href="#" class="link">Some Random Link</a>
I have a simple Animation when I hover over my Link. Basically the Underline slides out to the right, when I hover over the element and slides in from the left when I leave the element.
What I want to have is, that it plays the whole Animation when I'm hovering over the Element. I tried creating an Animation with @keyframes but couldn't get it work, because I don't know how to animate only the Pseudo-Class ::after and not the whole element.
Here's also a JSFiddle to better explain what I'm trying to do: JSFiddle