With the following code, I get the hover underline effect from left to right.
.underline { display: inline; position: relative; overflow: hidden; } .underline:after { content: ""; position: absolute; z-index: -1; left: 0; right: 100%; bottom: -5px; background: #000; height: 4px; transition-property: left right; transition-duration: 0.3s; transition-timing-function: ease-out; } .underline:hover:after, .underline:focus:after, .underline:active:after { right: 0; }
<p>hello, link is <a href="#" class="underline">underline</a> </p>
When not in hover, the: after element returns to the left, the original state. Is there a way in which : after going to the right , and not to the left, when you leave the hang?
source share