html5+css3 background-clip 技巧

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <style>
        body,html{
            margin: 0;
            padding: 0;
            background-image: url("image/timg.jpg");
            background-repeat: no-repeat;
            background-size: cover;
        }
        .box{
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
        }
        .box h1{
            font-size: 100px; 
            font-weight: 900;
            text-transform: uppercase;
            color:rgba(220, 210,154, 0.3);
            background-image: url("image/1.jpg");
            -webkit-background-clip:text;     /*background-clip 生效  颜色必须为透明状态的*/
            animation: a1 15s linear infinite;
        }
        @keyframes a1{
            100%{
                background-position: left 1000px; top: 0px;
            }
        }

    </style>

    <div class="box">
        <h1>animation</h1>
    </div>
</body>
</html>

 

posted @ 2019-08-26 15:33  WhiteSpace  阅读(277)  评论(0编辑  收藏  举报