JSFiddle - React, Tailwind, and code Playground
HTML
<a href='#'>hover!</a>
CSS
a {
background:#E32831;
padding:10px 15px;
display:inline-block;
box-sizing:border-box;
position:relative;
overflow:hidden;
color:white;
transition:all 200ms ease-in;
border-radius:5px;
font-family:arial;
text-decoration:none;
font-size:12px;
}
a:before, a:after {
display:block;
width:100%;
content:'';
box-sizing:border-box;
position:absolute;
height:0px;
border-radius:5px;
}
a:before {
border-top:1px solid red;
border-right:1px solid red;
left:-100%;
top:0;
height:0px;
}
a:after {
border-bottom:1px solid red;
border-left:1px solid red;
left:100%;
bottom:0;
height:0px;
}
@-webkit-keyframes left-up {
0% {
left:100%;
height:0;
}
50% {
left:0;
height:0;
}
100% {
height:100%;
left:0;
}
}
@-webkit-keyframes right-dn {
0% {
left:-100%;
height:0;
}
50% {
left:0;
height:0;
}
100% {
height:100%;
left:0;
}
}
@keyframes left-up {
0% {
left:100%;
height:0;
}
50% {
left:0;
height:0;
}
100% {
height:100%;
left:0;
}
}
@keyframes right-dn {
0% {
left:-100%;
height:0;
}
50% {
left:0;
height:0;
}
100% {
height:100%;
left:0;
}
}
a:hover {
background:lightgrey;
color:#808080;
}
a:hover:after, a:hover:before {
-webkit-animation-duration:900ms;
-webkit-animation-iteration-count: 1;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-fill-mode: forwards;
animation-duration:900ms;
animation-iteration-count: 1;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
}
a:hover:after {
-webkit-animation-name:left-up;
animation-name:left-up;
}
a:hover:before {
-webkit-animation-name:right-dn;
...