标签:head slide position tag round ann 进度 container doc
上篇博客做的动画解决了我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{ width: 50px; margin: 50px; } .progressBar { display: inline-block; width: 81%; height: 22px; background-color: rgba(0,0,0); margin-right: 3%; } #progressFill { width: 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({ width: "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);
标签:head slide position tag round ann 进度 container doc
原文地址:https://www.cnblogs.com/kaiqinzhang/p/10450118.html