<div id="container">
<button id="btn">ボタン</button>
</div>
#container {
text-align: center;
margin-top: 100px;
}
#btn {
padding: 20px 80px;
background: #fff;
border:1px solid #000;
position: relative;
overflow: hidden;
z-index: 1;
}
#btn:before {
content: "";
display: inline-block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #f00;
transform: translateX(-100%);
transition: transform 0.5s;
z-index: -1;
}
#btn:hover::before {
transform: translateX(0);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.