<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,
&::after {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: calc(100% + 2px);
height: calc(100% + 2px);
background-color: #5cc0ef;
transition: all 0.5s;
}
&::before {
clip-path: polygon(0 0, 100% 0, 80% 100%, 0 100%);
transform: translateX(-100%);
}
&::after {
clip-path: polygon(20% 0, 100% 0, 100% 100%, 0 100%);
transform: translateX(100%);
}
&:hover {
color: #fff;
&::before,
&::after {
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,
&::after {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: calc(100% + 2px);
height: calc(100% + 2px);
background-color: #5cc0ef;
transition: all 0.5s;
}
&::before {
clip-path: polygon(0 0, 80% 0, 100% 100%, 0 100%);
transform: translateX(-100%);
}
&::after {
clip-path: polygon(0 0, 100% 0, 100% 100%, 20% 100%);
transform: translateX(100%);
}
&:hover {
color: #fff;
&::before,
&::after {
transform: translateY(0);
}
}
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.