Result
ボタンがグラデーションなのでシャドウもグラデーションにしよう、みたいな提案
疑似要素に、グラデーションとblurを加えてグラデーションな影を生成しています
css
html, :root {/*CSS変数は必須ではありません*/
--blue: #0092ff;
--red: #ea4335;
}
button {/*ボタンのスタイル*/
font-family: "Roboto", sans-serif;
font-size: 16px;
position: relative;
outline: none;
border: none;
-webkit-appearance: none;
-webkit-tap-highlight-color: transparent;
cursor: pointer;
user-select: none;
padding: 0.75em 3em;
border-radius: 50px;
display: inline-block;
color: #fff;
background: linear-gradient(to right, var(--blue), var(--red));
}
button::after {/*グラデーションのシャドウ*/
content: "";
position: absolute;
z-index: -1;
bottom: -10px;
left: 5%;
height: 110%;
width: 90%;
opacity: 0.8;
border-radius: 50px;
background: linear-gradient(to right, var(--blue), var(--red));
filter: blur(6px);
transition: all 0.2s;
}
button:hover::after {
filter: blur(4px);
width: 100%;
bottom: -5px;
left: 0;
}
button:hover:active::after {
filter: blur(10px);
}
html
<button>button</button>
