1. 程式人生 > >點選元素或按鈕出現炫酷波紋

點選元素或按鈕出現炫酷波紋

<div class="container text-center">
        <div class="ripple" style="height:35px;">ripple</div>
        <button class="ripple">ripple set</button>
        <button class="ripple">ripple with very long content</button>
</div>

 .ripple {
        position: relative;
        overflow: hidden;  /*隱藏溢位的徑向漸變背景 */
    }

.ripple:after {
    content: "";
    display: block;
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, blue 10%, transparent 10.01%); /*設定徑向漸變 */
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform .3s, opacity .5s;
}

.ripple:active:after {  /*設定初始狀態 */
    transform: scale(0, 0);
    opacity: .3;
    transition: 0s;   
}
button{
    height:30px;

}