【CSS】css实现流光效果-按钮流光显示效果-自发光

 废话不多说,直接上代码

 


    Streamer
    * {
        padding: 0;
        margin: 0;
    }

    body {
        background-color: black;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
    }

    a {
        position: relative;
        width: 400px;
        height: 100px;
        line-height: 100px;
        font-size: 24px;
        text-transform: uppercase;
        text-decoration: none;
        text-align: center;
        color: #fff;
        border-radius: 50px;
        background-image: linear-gradient(to right, #03a9f4, #f441a5, #ffeb3d, #09a8f4);
        background-size: 400%;
        z-index: 1;
    }

    a::before {
        content: '';
        position: absolute;
        top: -5px;
        right: -5px;
        left: -5px;
        bottom: -5px;
        border-radius: 50px;
        background-image: linear-gradient(to right, #03a9f4, #f441a5, #ffeb3d, #09a8f4);
        background-size: 400%;
        z-index: -1;
        filter: blur(20px);
    }

    a:hover {
        animation: sun 8s infinite;
    }

    a:hover::before {
        animation: sun 8s infinite;
    }

    @keyframes sun {
        100% {
            background-position: -400% 0;
        }
    }

 

最终效果如下

 

 

你可能感兴趣的:(CSS,css,html,javascript)