纯CSS实现动态进度条

寻技术 Html/CSS 2023年07月11日 66
 <!DOCTYPE html>
 <html>
 <head>
   <title>'</title>
 </head>
 <style type="text/css">
   #main{
     width: 300px;
     height: 30px;
     background: #ccc;
   }
 
   #sub{
     
     animation: removef 2s ease-in;
     -webkit-animation:removef 2s ease-in;
     background: #aacc33;
     height: 100%;
     width: 80%;
   }
 
   @keyframes removef{
     0% {width: 0%;}
     100% {width: 80%;}
 
   }
   @-webkit-keyframes removef{
      0% {width: 0%;}
      100% {width: 80%;}
   }
 
      #progress{
   width: 50%;
   height: 30px;
   border:1px solid #ccc;
   border-radius: 15px;
   margin: 50px 0 0 100px;
   overflow: hidden;
   box-shadow: 0 0 5px 0px #ddd inset;
 }
 #progress span {
   display: inline-block;
   width: 80%;
   height: 100%;
   background: #2989d8;
   text-align: center;
   color:#fff;
   -webkit-animation:load 3s ease-in;
 }
 @-webkit-keyframes load{
   0%{
     width: 0%;
   }
   100%{
     width:80%;
   }
 }
 
 .circleProgress_wrapper{
   width: 200px;
   height: 200px;
   margin: 50px auto;
   position: relative;
   border:1px solid #ddd;
 }
 .wrapper{
   width: 100px;
   height: 200px;
   position: absolute;
   top:0;
   overflow: hidden;
 }
 .right{
   right:0;
 }
 .left{
   left:0;
 }
 .circleProgress{
   width: 160px;
   height: 160px;
   border:20px solid rgb(232, 232, 12);
   border-radius: 50%;
   position: absolute;
   top:0;
   -webkit-transform: rotate(45deg);
 }
 .rightcircle{
   border-top:20px solid green;
   border-right:20px solid green;
   right:0;
   -webkit-animation: circleProgressLoad_right 5s linear infinite;
 }
 .leftcircle{
   border-bottom:20px solid green;
   border-left:20px solid green;
   left:0;
   -webkit-animation: circleProgressLoad_left 5s linear infinite;
 }
 @-webkit-keyframes circleProgressLoad_right{
   0%{
     border-top:20px solid #ED1A1A;
     border-right:20px solid #ED1A1A;
     -webkit-transform: rotate(45deg);
   }
   50%{
     border-top:20px solid rgb(232, 232, 12);
     border-right:20px solid rgb(232, 232, 12);
     border-left:20px solid rgb(81, 197, 81);
     border-bottom:20px solid rgb(81, 197, 81);
     -webkit-transform: rotate(225deg);
   }
   100%{
     border-left:20px solid green;
     border-bottom:20px solid green;
     -webkit-transform: rotate(225deg);
   }
 }
 @-webkit-keyframes circleProgressLoad_left{
   0%{
     border-bottom:20px solid #ED1A1A;
     border-left:20px solid #ED1A1A;
     -webkit-transform: rotate(45deg);
   }
   50%{
     border-bottom:20px solid rgb(232, 232, 12);
     border-left:20px solid rgb(232, 232, 12);
     border-top:20px solid rgb(81, 197, 81);
     border-right:20px solid rgb(81, 197, 81);
     -webkit-transform: rotate(45deg);
   }
   100%{
     border-top:20px solid green;
     border-right:20px solid green;
     border-bottom:20px solid green;
     border-left:20px solid green;
     -webkit-transform: rotate(225deg);
   }
 }
 </style>
 <body>
 <div >
   <div ></div>
 </div>
 <div >
   <span></span>
 </div>
 
 <div class="circleProgress_wrapper">
         <div class="wrapper right">
             <div class="circleProgress rightcircle"></div>
         </div>
         <div class="wrapper left">
             <div class="circleProgress leftcircle"></div>
         </div>
  </div>
     
 </body>
 </html>

 

关闭

用微信“扫一扫”