<a href="#" class="p-anima-1 c-btn">button</a>
.p-anima-1 {
background-color: #333;
background-repeat: no-repeat;
background-position: 100% 0;
background-size: 200% auto;
background-image: linear-gradient(to right, #6667ab 0%, #6667ab 50%, #333 50%, #333 100%);
transition: color 0.4s, background-position 0.4s;
}
.p-anima-1:hover {
background-position: 0 0;
}
/* アニメーションとは関係のないスタイル(ボタンの見た目など) */
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.c-btn {
display: block;
color: #fff;
font-size: 20px;
font-weight: bold;
text-align: center;
background-color: #333;
border-radius: 3px;
width: 300px;
margin: auto;
padding: 20px 0;
text-decoration: none;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.