手机端开机光斑渐变

-webkit-background-clip:text;
让背景只在文本中显示。

    * {
      margin: 0;
      padding: 0;
    }
    html,body {
      overflow: hidden;
      height: 100%;
      text-align: center;
      background-color: #000;
    }
    h1 {
      display: inline-block;
      margin-top: 50px;
      color: rgba(255,255, 255, .3);
      background-image: linear-gradient(110deg,rgba(255,255,255,0) 10px,rgba(255,255,255,1) 20px,rgba(255,255,255,0) 30px);
      background-position: -20px;
      background-repeat: no-repeat;
      -webkit-background-clip: text;
    }
  <h1>无悟饭空wufankong</h1>
  <script>
    var h1 = document.querySelector('h1');
    var flag = 0;
    setInterval(function(){
      flag = flag+10;
      if(flag >= 320) {
        flag = -20;
      }
      h1.style.backgroundPosition = flag +'px 0px';
    },100)
  </script>
发布了64 篇原创文章 · 获赞 0 · 访问量 320

猜你喜欢

转载自blog.csdn.net/weixin_43269800/article/details/103935376
今日推荐