欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

css3+javascript按鈕水波紋效果怎么實現(xiàn)

小編給大家分享一下css3+javascript按鈕水波紋效果怎么實現(xiàn),希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

站在用戶的角度思考問題,與客戶深入溝通,找到天水網(wǎng)站設(shè)計與天水網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:網(wǎng)站制作、網(wǎng)站設(shè)計、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、國際域名空間、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務(wù)覆蓋天水地區(qū)。

css3+js實現(xiàn)按鈕水紋漣漪效果

HTML

  • 首先我們用<a>標(biāo)簽定義兩個按鈕

<a href="#">button</a>
<a href="#">button</a>

CSS3

  • 調(diào)整布局樣式

  • 色彩范圍

* {
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif; /* 字體 */
}

body {
    display: flex;
    justify-content: center;/* 彈性盒子 */
    align-items: center;
    min-height: 100vh;
    flex-direction: column;
    background: #1f2a33;
}

a {
    position: relative;
    display: inline-block;
    padding: 12px 36px;
    margin: 10px 0;
    color: #fff;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 18px;
    letter-spacing: 2px;
    border-radius: 40px;
    overflow: hidden;
    background: linear-gradient(90deg, #0162c8, #55e7fc);
}
/* 子偽類選擇器 */
a:nth-child(2) {
    background: linear-gradient(90deg, #755bea, #ff72c0);
}

span {
    position: absolute;
    background: #fff;
    transform: translate(-50%, -50%);
    pointer-events: none;
    border-radius: 50%;
    animation: animate 1s linear infinite;
}

@keyframes animate {
    0% {
        width: 0px;
        height: 0px;
        opacity: 0.5;
    }
    100% {
        width: 500px;
        height: 500px;
        opacity: 0;
    }
}

JavaScript

  • 啟用 js 監(jiān)聽事件

  • 定時器

  • 目的:控制動畫和單位時間內(nèi)點擊效果統(tǒng)一

const buttons = document.querySelectorAll('a');

buttons.forEach(btn => { //箭頭函數(shù) (ES6)

    btn.addEventListener('click', function (e) {
        let x = e.clientX - e.target.offsetLeft;
        let y = e.clientY - e.target.offsetTop;
        
        let ripples = document.createElement('span');
        
        ripples.style.left = x + 'px';
        ripples.style.top = y + 'px';
        
        this.appendChild(ripples);
        setTimeout(() => {
            ripples.remove()
        }, 1000);
    })
})

效果圖:

css3+javascript按鈕水波紋效果怎么實現(xiàn)

看完了這篇文章,相信你對“css3+javascript按鈕水波紋效果怎么實現(xiàn)”有了一定的了解,如果想了解更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

文章標(biāo)題:css3+javascript按鈕水波紋效果怎么實現(xiàn)
文章出自:http://chinadenli.net/article18/ihosdp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄網(wǎng)站改版標(biāo)簽優(yōu)化外貿(mào)網(wǎng)站建設(shè)網(wǎng)站建設(shè)網(wǎng)站內(nèi)鏈

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作