zoukankan      html  css  js  c++  java
  • css3 线性渐变和径向渐变

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title>线性渐变和径向渐变</title>
            <style type="text/css">
                #dd{
                     500px;
                    height: 200px;
                    /*线性渐变*/
                    background-image: linear-gradient(red,yellow);
                }
                #dd1{
                     500px;
                    height: 200px;
                    /*方向线性渐变*/
                    background-image: linear-gradient(to top right,red,yellow);
                }
                #dd2{
                     500px;
                    height: 200px;
                    /*角度线性渐变*/
                    background-image: linear-gradient(45deg,red,yellow);
                }
                #dd3{
                     500px;
                    height: 200px;
                    /*多种颜色等比例渐变*/
                    background-image: linear-gradient(to bottom right,red 0%,yellow 30%, orange 60%,green 100%);
                }
                #dd4{
                     500px;
                    height: 200px;
                    /*径向渐变*/
                    background-image: radial-gradient(green,blue);
                }
                #dd5{
                     500px;
                    height: 200px;
                    /*椭圆径向渐变*/
                    background-image: radial-gradient(ellipse,red,yellow);
                }
                #dd6{
                     500px;
                    height: 200px;
                    /*圆形可设置大小的径向渐变*/
                    background-image: radial-gradient(circle 100px,#000,#ff0000);
                }
                #dd7{
                     500px;
                    height: 200px;
                    /*重复的径向渐变*/
                    background-image:repeating-radial-gradient(circle 50px,#000,#ff0000);
                }
                /* 文字渐变 */
                .text-gradient {  
                    display: inline-block;
                    font-family: '微软雅黑';
                    font-size: 10em;
                    position: relative; 
                }  
                  
                .text-gradient[data-text]::after {  
                    content: attr(data-text);  
                    color: #FBEE00;  
                    position: absolute;  
                    left: 0;  
                    z-index: 2;
                    -webkit-mask-image: -webkit-gradient(linear, 0 0, 0 bottom, from(#FBEE00), to(rgba(251,246,147,.6)));
                }
            </style>
        </head>
        <body>
            <h1>线性渐变</h1>
            <div id="dd">
                线性渐变
            </div>
            <div id="dd1">
                方向线性渐变
            </div>
            <div id="dd2">
                角度线性渐变
            </div>
            <div id="dd3">
                多种颜色等比例渐变
            </div>
            <h1>径向渐变</h1>
            <div id="dd4">
                两种颜色径向渐变
            </div>
            <div id="dd5">
                椭圆径向渐变
            </div>
            <div id="dd6">
                圆形可设置大小的径向渐变
            </div>
            <div id="dd7">
                重复的径向渐变
            </div>
            <h2 class="text-gradient" data-text="文字渐变">文字渐变</h2> 
        </body>
    </html>
    <script>
        var dd = document.getElementById("dd7");
        var xd = 50;
        setInterval(function(){
            xd+=5;
            if(xd>=100){
                xd=50;
            }
            dd.style.backgroundImage='repeating-radial-gradient(circle '+xd+'px,red,yellow)';
        },100);
    </script>
  • 相关阅读:
    移动web前端高效开发实践 读书笔记
    前端开发最佳实践-读书笔记
    frontend-Tips
    匿名函数的几种写法
    12个用得着的JQuery代码片段(转)
    tesseract-ocr 学习笔记(比网上的中文说明都详细)
    关于大数据的思考
    单片机实验的小记录~~PWM
    组建Redis集群遇到`GLIBC_2.14' not found和ps -ef 不显示用户名
    柔性数组(Redis源码学习)
  • 原文地址:https://www.cnblogs.com/xianxianxxx/p/9646351.html
Copyright © 2011-2022 走看看