これは、cssを使用することによってのみ達成できます。 jqueryを使用する必要はありません。 .button、.button:after、および.button:active:afterイベントのCSSを記述する必要があります(ボタンがクラス名またはボタンであると仮定します)。ここで
私はそれは、すべてのCSSだ
<!DOCTYPE html>
<html>
<head>
<style>
.button {
text-transform: uppercase;
border: none;
-webkit-box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.4);
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.4);
-webkit-transition: all 0.4s;
-o-transition: all 0.4s;
transition: all 0.4s;
position: relative;
display: inline-block;
margin-bottom: 0;
font-weight: normal;
text-align: center;
vertical-align: middle;
/*-ms-touch-action: manipulation;*/
/*touch-action: manipulation;*/
cursor: pointer;
background-image: none;
border: 1px solid transparent;
white-space: nowrap;
padding: 6px 16px;
font-size: 13px;
line-height: 1.846;
border-radius: 3px;
}
.button:after {
content: "";
display: block;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-image: -webkit-radial-gradient(circle, #000000 10%, transparent 10.01%);
background-image: -o-radial-gradient(circle, #000000 10%, transparent 10.01%);
background-image: radial-gradient(circle, #000000 10%, transparent 10.01%);
background-repeat: no-repeat;
-webkit-background-size: 1000% 1000%;
background-size: 1000% 1000%;
background-position: 50%;
opacity: 0;
pointer-events: none;
-webkit-transition: background .5s, opacity 1s;
-o-transition: background .5s, opacity 1s;
transition: background .5s, opacity 1s;
}
.button:active:after {
-webkit-background-size: 0% 0%;
background-size: 0% 0%;
opacity: .2;
-webkit-transition: 0s;
-o-transition: 0s;
transition: 0s;
}
</style>
</head>
<body>
<h2>Animated Button - Ripple Effect</h2>
<button class="button">Click Me</button>
</body>
</html>
で試してみましたCSSです。彼らは、要素の ':active'状態によってトリガされた遷移を使用しています。開発者ツールを使用して問題の要素を調べます。 Chromeの場合、'Styles'タブの下に ':hov'タブがあり、ボタンにさまざまな状態を適用できます。ボタンに ':active'を適用します。ボタンのスタイルと擬似後要素のスタイルを調べます。 – hungerstar