<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<style>@charset "utf-8";
/*丸がボタンに変形する*/
.btntransform {
display: inline-block;
margin: 20px 0;
text-decoration: none;
outline: none;
font-size: max(14px, 2vw);
white-space: nowrap;
width: max(150px, 40vw);
/*丸の基点とするためrelativeを指定*/
position: relative;
/*ボタンの形状*/
padding: 0 0 0 15px;
line-height: 50px;
color: #333;
}
/* 丸が動く */
.btntransform::before {
content: "";
/*絶対配置で丸の位置を決める*/
position: absolute;
left: 0;
z-index: -1;
/*丸の形状*/
width: 50px;
height: 50px;
background: linear-gradient(to right, #6551ff 0%, #00e2fa 80%, #00e2fa 100%);
border-radius: 25px;
/*アニメーションの指定*/
transition: 0.3s ease-out;
}
/*hoverした際の形状*/
.btntransform:hover::before {
width: max(180px, 45vw);
}
/* 矢印の形状 */
.btntransform::after {
position: absolute;
content: "";
top: 1.4rem;
right: -15px;
width: 5px;
height: 5px;
border-top: 1px solid #000;
border-right: 1px solid #000;
transform: rotate(45deg);
}
/*========= レイアウトのためのCSS ===============*/
body {
width: 100%;
height: 100vh;
vertical-align: middle;
padding: 30px 0;
text-align: center;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
background-image: linear-gradient(
103.3deg,
rgba(252, 225, 208, 1) 30%,
rgba(255, 173, 214, 1) 55.7%,
rgba(162, 186, 245, 1) 81.8%
);
}
/*ボタンの配置*/
.btn-position {
display: flex;
flex-direction: column;
align-items: center;
}
p {
margin: 0 0 10px 0;
}</style>
</head>
<body>
<body>
<div class="btn-position">
<a href="#" class="btntransform">丸がボタンに変形する</a>
</div>
<script>
</script>
</body>
</html>
/*
外部依存 CSS:
- https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css
*/
@charset "utf-8";
/*丸がボタンに変形する*/
.btntransform {
display: inline-block;
margin: 20px 0;
text-decoration: none;
outline: none;
font-size: max(14px, 2vw);
white-space: nowrap;
width: max(150px, 40vw);
/*丸の基点とするためrelativeを指定*/
position: relative;
/*ボタンの形状*/
padding: 0 0 0 15px;
line-height: 50px;
color: #333;
}
/* 丸が動く */
.btntransform::before {
content: "";
/*絶対配置で丸の位置を決める*/
position: absolute;
left: 0;
z-index: -1;
/*丸の形状*/
width: 50px;
height: 50px;
background: linear-gradient(to right, #6551ff 0%, #00e2fa 80%, #00e2fa 100%);
border-radius: 25px;
/*アニメーションの指定*/
transition: 0.3s ease-out;
}
/*hoverした際の形状*/
.btntransform:hover::before {
width: max(180px, 45vw);
}
/* 矢印の形状 */
.btntransform::after {
position: absolute;
content: "";
top: 1.4rem;
right: -15px;
width: 5px;
height: 5px;
border-top: 1px solid #000;
border-right: 1px solid #000;
transform: rotate(45deg);
}
/*========= レイアウトのためのCSS ===============*/
body {
width: 100%;
height: 100vh;
vertical-align: middle;
padding: 30px 0;
text-align: center;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
background-image: linear-gradient(
103.3deg,
rgba(252, 225, 208, 1) 30%,
rgba(255, 173, 214, 1) 55.7%,
rgba(162, 186, 245, 1) 81.8%
);
}
/*ボタンの配置*/
.btn-position {
display: flex;
flex-direction: column;
align-items: center;
}
p {
margin: 0 0 10px 0;
}
/*
外部依存 CSS (このデモは下記の CSS にも依存します):
- https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css
*/