zoukankan      html  css  js  c++  java
  • 动画解决方案(二)

    上篇博客做的动画解决了我banner卡顿的问题,但之前还试了用jquery的animation,虽然依然卡顿,但不失为一种方法。

    1.jquery的animation

    <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8">
      <title>进度条</title>
      <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
      <style type="text/css">
        .container{
           50px;
          margin: 50px;
        }
        .progressBar {
          display: inline-block;
           81%;
          height: 22px;
          background-color: rgba(0,0,0);
          margin-right: 3%;
        }
        #progressFill {
           0%;
          height: 22px;
          position: relative;
          background-color: red;
          background-size: 3em 3em;
          animation: warning-animation 750ms infinite linear;
        }
      
      @keyframes warning-animation {
          0% {
              background-position: 0 0;
          }
          100% {
              background-position: 3em 0;
          }
      }
      .progressText, #percentage {
        display: inline-block;
        margin-top: -11px;
        vertical-align: middle;
      }
      </style>     
    </head>
    <body>
      <button id = "begin">点击开始</button>
      <div class="container">
        <span class = "progressBar">
          <div id = "progressFill"></div>
        </span>
        <span class = "progressText"> 进度  </span>
        <span id = "percentage">0%</span>
      </div>  
    </body>
    <script>
      $("#begin").on("click",function(){
        $("#progressFill").animate({ 
           "100%"
        }, 8000);
        
      })
    </script>
    </html>

    2.出了这个,还可以使用js控制width,(但也会出现卡顿,这种要保证width每42ms改变一次)。

    let pro = 0;
    this.timer = setInterval(function () {
        if (pro < 50) {
            pro++;
        } else {
            clearInterval(this.timer_i);
        }
        if (slider.currentSlide !== i) {
            pro = 0;
        }
        bar.width(pro + "px");
    }, 160);
  • 相关阅读:
    操作系统六文件管理
    Educational Codeforces Round 38 (Rated for Div. 2) ABCD
    51nod 1100 斜率最大
    51nod 最小方差
    51nod 1065 最小正子段和
    P1280 尼克的任务
    牛客小白月赛2
    Codeforces Round #210 (Div. 1) B 二分+dp
    江西财经大学第一届程序设计竞赛
    51nod 1596 搬货物
  • 原文地址:https://www.cnblogs.com/kaiqinzhang/p/10450118.html
Copyright © 2011-2022 走看看