html+css 炫彩流光按钮

先上效果 

上代码  通俗易懂

<!DOCTYPE html>
<html lang="en">

<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>
        * {
            display: 0;
            margin: 0;
        }

        html,
        body {
            height: 100%;
            background-color: black;
            
        }
       /* 设置按钮样式*/
        .top_btn {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            /*设置渐变颜色*/
            background: linear-gradient(45deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);
            background-size: 400%;
            font-size: 24px;
            color: #fff;
            width: 400px;
            text-align: center;
            line-height: 100px;
            height: 100px;
            border-radius: 50px;
            /* 变为大写字母 */
            text-transform: uppercase;
            z-index: 1;
        }

        a::before {

            position: absolute;
            content: '';
            top: -5px;
            left: -5px;
            right: -5px;
            bottom: -5px;
            background: linear-gradient(45deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);
            border-radius: 50px;
            /* 滤镜 */
            filter: blur(20px);
            z-index: -1;
        }

        a:hover {
            /* infinite无限循环 */
            animation: sun 8s infinite;
        }

        /* 伪元素动画 */
        a:hover::before {
            animation: sun 8s infinite;
        }

        @keyframes sun {
            100% {
                background-position: -400% 0;
            }
        }
    </style>
</head>

<body>
    <!-- <div class="top"> -->
        <a class="top_btn">
            按钮
        </a>
    <!-- </div> -->
</body>

</html>

猜你喜欢

转载自blog.csdn.net/Z_Gleng/article/details/126675722