溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

html+css魔幻霓虹燈文字特效怎么實(shí)現(xiàn)

發(fā)布時(shí)間:2023-05-11 14:40:02 來源:億速云 閱讀:136 作者:iii 欄目:開發(fā)技術(shù)

這篇文章主要介紹“html+css魔幻霓虹燈文字特效怎么實(shí)現(xiàn)”的相關(guān)知識,小編通過實(shí)際案例向大家展示操作過程,操作方法簡單快捷,實(shí)用性強(qiáng),希望這篇“html+css魔幻霓虹燈文字特效怎么實(shí)現(xiàn)”文章能幫助大家解決問題。

    實(shí)現(xiàn)過程(完整源碼在最后):

    1. 定義h4標(biāo)簽:

    <h4>Aurora Borealis night</h4>

    2. 給個(gè)body背景色:

       body{
                background-color: rgb(4, 15, 36);
            }

    3. 設(shè)置h4基本樣式:

     h4{
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%,-50%);
                width: 100%;
                text-align: center;
                font-size: 3em;
                text-transform: uppercase;
                letter-spacing: 10px;
                color: rgb(4, 15, 36); 
                -webkit-box-reflect: below 1px linear-gradient(transparent ,rgb(218, 218, 218));
                animation: san 6s linear infinite;
            }

    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%); 居中對齊。先left與top 50%,再偏移自身長度與寬度50%達(dá)到居中。
    text-align: center; 文字居中。
    text-transform: uppercase; 字母變?yōu)榇髮憽?br/>letter-spacing: 10px; 每個(gè)字符間距離。
    -webkit-box-reflect: 倒影效果。
    animation: san 6s linear infinite; 定義動畫。

    4.定義動畫,就是設(shè)置不同時(shí)間段顯示不同顏色等實(shí)現(xiàn)閃爍霓虹燈效果~時(shí)間可以自己調(diào)自己要的效果:

      @keyframes san{
                0%,15%,50%,52%,70%,90%,99.1%{
                    color: rgb(4, 15, 36);
                    filter: blur(2px);
                }
                12%,15.1%,60%,70.1%,90.5%,100%{
                    color: rgb(255, 255, 255);
                    text-shadow: 0 0 5px rgb(22, 138, 216),
                    0 0 25px rgb(22, 138, 216),
                    0 0 35px rgb(22, 138, 216),
                    0 0 105px rgb(22, 138, 216),
                    0 0 155px rgb(22, 138, 216);
                    filter: blur(0px);
                }
            }

    filter: blur(2px); 模糊
    text-shadow: 0 0 5px rgb(22, 138, 216),
    0 0 25px rgb(22, 138, 216),
    0 0 35px rgb(22, 138, 216),
    0 0 105px rgb(22, 138, 216),
    0 0 155px rgb(22, 138, 216);
    文字陰影。寫多行是為了陰影疊加,效果更亮。

    完整源碼:

    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            *{
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }
            body{
                background-color: rgb(4, 15, 36);
            }
            h4{
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%,-50%);
                width: 100%;
                text-align: center;
                font-size: 3em;
                text-transform: uppercase;
                letter-spacing: 10px;
                color: rgb(4, 15, 36); 
                -webkit-box-reflect: below 1px linear-gradient(transparent ,rgb(218, 218, 218));
                animation: san 6s linear infinite;
            }
            @keyframes san{
                0%,15%,50%,52%,70%,90%,99.1%{
                    color: rgb(4, 15, 36);
                    filter: blur(2px);
                }
                12%,15.1%,60%,70.1%,90.5%,100%{
                    color: rgb(255, 255, 255);
                    text-shadow: 0 0 5px rgb(22, 138, 216),
                    0 0 25px rgb(22, 138, 216),
                    0 0 35px rgb(22, 138, 216),
                    0 0 105px rgb(22, 138, 216),
                    0 0 155px rgb(22, 138, 216);
                    filter: blur(0px);
                }
            }
        </style>
    </head>
    <body>
        <h4>Aurora Borealis night</h4>
    </body>
    </html>

    關(guān)于“html+css魔幻霓虹燈文字特效怎么實(shí)現(xiàn)”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識,可以關(guān)注億速云行業(yè)資訊頻道,小編每天都會為大家更新不同的知識點(diǎn)。

    向AI問一下細(xì)節(jié)

    免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

    AI