前端简单效果 图片在文字里移动(可以做文字水波流动)

109 阅读1分钟

background-clip 有兼容问题,所以替换成 -webkit-background-clip

image.png

<!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>
    *{
      margin: 0;
      padding: 0;
    }
    body{
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }
    .water h1{
      font-size: 10rem;
      color: rgba(255, 255, 255, .1);
      background: url(图片地址) repeat-x;
      -webkit-background-clip: text;
      animation: animate 12s linear infinite;
    }
    @keyframes animate {
      0%{
        background-position: left 0px top 80px;
      }
      40%{
        background-position: left 800px top -50px;
      }
      80%{
        background-position: left 1800px top -50px;
      }
      100%{
        background-position: left 2400px top 80px;
      }
    }
  </style>
</head>
<body>
  <div class="water">
    <h1>WATER</h1>
  </div>
</body>
</html>