<div class="layout">
<!-- ここからボタンのHTML -->
<!-- ボタンの背景が左上から現れるアニメーション -->
<div class="button-01">
<a href="#"><span>ボタン</span></a>
</div>
<!-- ボタンの背景が左下から現れるアニメーション -->
<div class="button-02">
<a href="#"><span>ボタン</span></a>
</div>
<!-- ここまでボタンのHTML -->
</div>
/* ここはレイアウトなのでボタンとは関係ない */
* {
margin: 0;
}
.layout {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
gap: 50px;
width: 100%;
height: 100vh;
}
/* ここからボタンのCSS */
.button-01 {
a {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 240px;
height: 50px;
font-size: 16px;
text-decoration: none;
color: #5cc0ef;
border: 1px solid #5cc0ef;
overflow: hidden;
transition: all 0.3s;
span {
position: relative;
z-index: 1;
}
&::before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 50%;
width: calc(100% + 30%);
height: calc(100% + 2px);
clip-path: polygon(0 0, 100% 0, 80% 100%, 0% 100%);
background-color: #5cc0ef;
transform: translateX(-100%);
transition: all 0.4s;
}
&:hover {
color: #fff;
&::before {
transform: translateY(0);
}
}
}
}
.button-02 {
a {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 240px;
height: 50px;
font-size: 16px;
text-decoration: none;
color: #5cc0ef;
border: 1px solid #5cc0ef;
overflow: hidden;
transition: all 0.3s;
span {
position: relative;
z-index: 1;
}
&::before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 50%;
width: calc(100% + 30%);
height: calc(100% + 2px);
clip-path: polygon(0 0, 80% 0%, 100% 100%, 0% 100%);
background-color: #5cc0ef;
transform: translateX(-100%);
transition: all 0.4s;
}
&:hover {
color: #fff;
&::before {
transform: translateY(0);
}
}
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.