zoukankan      html  css  js  c++  java
  • 16.纯 CSS 创作一个渐变色动画边框

    原文地址:https://segmentfault.com/a/1190000014785816

    感想:边框是伪元素::after来的;

    HTML代码:

    <div class="box">
        you are my<br>
        FAVORIFE
    </div>

    CSS代码:

    html, body,.box {
        margin: 0;
        padding: 0;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    body{
        background: #222;
    }
    .box{
        width: 10em;
        height: 5em;
        border-radius: 0.2em;
        line-height: 1.5em;
        font-size: 2.5em;
        /* 字体系列:无衬线;*/
        font-family: sans-serif;
        color: white;
        background: #111;
        position: relative;
        animation: animate_text 2s linear infinite alternate;
    }
    @keyframes animate_text{
        from{
            color: lime;
        }
        to{
            color: yellow;
        }
    }
    /* 用伪圆增加一个背板 */
    .box::after{
        content: '';
        position: absolute;
        width: 102%;
        height: 104%;
        background-image: linear-gradient(60deg, aquamarine, cornflowerblue, goldenrod, hotpink, salmon, lightgreen, sandybrown, violet);
        background-size: 300%;
        border-radius: 0.2em;
        z-index: -1;
        animation: animate_bg 5s infinite;
    }
    @keyframes animate_bg{
        0%{
            background-position: 0%, 50%;
        }
        50%{
            background-position: 100%, 50%;
        }
        100%{
            background-position: 0%, 50%;
        }
    }
    作者:人生与戏
    本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
  • 相关阅读:
    复利计算-做汉堡,结对2.0-复利计算再升级
    java集合
    java 封装,继承,多态基础
    购物车
    ajax
    演示
    实验四
    实验三
    构建之法6-7章读后感
    作业调度模拟程序
  • 原文地址:https://www.cnblogs.com/FlyingLiao/p/10241519.html
Copyright © 2011-2022 走看看