zoukankan      html  css  js  c++  java
  • 炫彩按钮源码分析

    炫彩按钮源码分析

    1

    简介:

    用基础css做一个有一点炫酷的流光按钮,不止按钮,只要是盒子就行。

    具体步骤:

    button按钮源码

    1.先定义一个盒子当做按钮,如我就用a标签:

    <body>
        <a href="#" class="guang">button</a>
    </body>

    a标签CSS

    2.先给a标签写基础的样式,比如长宽等等…:

     .guang{
            position: relative;
            display: inline-block;
            width: 220px;
            height: 80px;
            color: rgb(255, 255, 255);
            line-height: 80px;
            font-size: 35px;
            font-family: sans-serif;
            text-decoration: none;
            text-transform: uppercase;
            text-align: center;
            border-radius: 30px;
            background: linear-gradient(90deg,rgb(39, 122, 218),rgb(74, 230, 121),rgb(201, 214, 13),rgb(226, 20, 233),rgb(16, 172, 219));
            background-size: 400%;
            z-index: 1;
            text-shadow: 0 0 5px white,
                         0 0 5px white;
        }

    注意:其中一些属性用处:
    text-transform: uppercase; 全部换成大写字母。
    background: linear-gradient(…); 线性颜色渐变,可以改成自己要的颜色。
    text-shadow: 0 0 5px white,
    0 0 5px white;
    写两行是为了让字体更亮。

    鼠标悬浮

    3.鼠标经过盒子产生流光的动画:

     .guang:hover{
            animation: move 5s linear alternate infinite;
        }
        @keyframes move{
            0%{
               background-position: 0%;
            }
            100%{
                background-position: 100%;
            }
        }

    阴影样式

    4.定义盒子周围的光晕阴影:

     .guang::before{
            content: '';
            position: absolute;
            top: -10px;
            left: -10px;
            width: 240px;
            height: 100px;
            background: linear-gradient(90deg,rgb(39, 122, 218),rgb(74, 230, 121),rgb(243, 169, 10),rgb(226, 20, 233),rgb(16, 172, 219));
            background-size: 400%;
            opacity: 0;
            z-index: -1;
            border-radius: 45px;
            transition: 0.6s;
           
        }
      .guang:hover::before{
            filter: blur(15px);
            opacity: 1;
            animation: move 8s linear alternate infinite;
        }

    注意:其中一些属性用处:
    filter: blur 滤镜,就是让其模糊

    完整代码:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body{
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: black;
        }
        .guang{
            position: relative;
            display: inline-block;
            width: 220px;
            height: 80px;
            color: rgb(255, 255, 255);
            line-height: 80px;
            font-size: 35px;
            font-family: sans-serif;
            text-decoration: none;
            text-transform: uppercase;
            text-align: center;
            border-radius: 30px;
            background: linear-gradient(90deg,rgb(39, 122, 218),rgb(74, 230, 121),rgb(201, 214, 13),rgb(226, 20, 233),rgb(16, 172, 219));
            background-size: 400%;
            z-index: 1;
            text-shadow: 0 0 5px white,
                         0 0 5px white;
        }
        .guang:hover{
            animation: move 5s linear alternate infinite;
        }
        @keyframes move{
            0%{
               background-position: 0%;
            }
            100%{
                background-position: 100%;
            }
        }
        .guang::before{
            content: '';
            position: absolute;
            top: -10px;
            left: -10px;
            width: 240px;
            height: 100px;
            background: linear-gradient(90deg,rgb(39, 122, 218),rgb(74, 230, 121),rgb(243, 169, 10),rgb(226, 20, 233),rgb(16, 172, 219));
            background-size: 400%;
            opacity: 0;
            z-index: -1;
            border-radius: 45px;
            transition: 0.6s;
           
        }
        .guang:hover::before{
            filter: blur(15px);
            opacity: 1;
            animation: move 8s linear alternate infinite;
        }
    </style>
    <body>
        <a href="#" class="guang">button</a>
    </body>
    </html>
  • 相关阅读:
    关机相关(shutdown,reboot)
    软件架构学习小结
    颜色空间RGB与HSV(HSL)的转换
    OData语法
    拷贝构造函数,深拷贝,大约delete和default相关业务,explicit,给定初始类,构造函数和析构函数,成员函数和内联函数,关于记忆储存,默认参数,静态功能和正常功能,const功能,朋友
    登录模块
    TextView 使用自定义的字体和亮点
    基于Hama并联平台Finding a Maximal Independent Set 设计与实现算法
    VS2012使用XListCtrl
    ThinkPHP 3.2 开放 cache注缓存,过滤非法字符
  • 原文地址:https://www.cnblogs.com/cainiao-chuanqi/p/14177384.html
Copyright © 2011-2022 走看看