サンプル
See the Pen Codepen by Tora (@webtoranomaki) on CodePen.
コード
<a class="btn btn01" href="#">Button</a>
.btn {
display: inline-block;
width: 200px;
height: 50px;
line-height: 50px;
text-align: center;
-webkit-transition: .3s;
transition: .3s;
}
.btn01 {
position: relative;
color: #fff;
border: 1px solid #333;
background-color: #333;
z-index: 2;
}
.btn01::before,
.btn01::after {
position: absolute;
display: block;
content: '';
top: 0;
width: 50%;
height: 100%;
background-color: #333;
z-index: -1;
-webkit-transition: .3s;
transition: .3s;
}
.btn01::before {
left: 0;
}
.btn01::after {
right: 0;
}
.btn01:hover {
border-color: #069;
background-color: #fff;
color: #069;
}
.btn01:hover::before,
.btn01:hover::after {
width: 0;
background-color: #069;
}
記事の補足・今後追加したい内容
- 背景が上下に開く場合のボタンサンプル。