Pada snippet ini kita akan melakukan swapping button dari kiri ke kanan.
body {
margin: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
font-family: sans-serif;
background-color: grey;
}
a {
padding: 20px 40px;
text-transform: uppercase;
text-decoration: none;
letter-spacing: 4px;
color: transparent;
border: 3px solid #ff0;
font-size: 30px;
position: relative;
}
a:before {
content: 'button';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #363636;
color: #ff0;
display: flex;
justify-content: center;
align-items: center;
transition: all 0.5s;
}
a:hover:before {
left: 100%;
transform: scale(0) rotateY(360deg);
opacity: 0;
}
a:after {
content: 'button';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background-color: #363636;
color: #ff0;
display: flex;
justify-content: center;
align-items: center;
transition: all 0.5s;
transform: scale(0) rotateY(0deg);
opacity: 0;
}
a:hover:after {
left: 0;
transform: scale(1) rotateY(360deg);
opacity: 1;
}