亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

用百分比數字更新進度條?

用百分比數字更新進度條?

呼啦一陣風 2023-10-20 16:22:13
我有一個動畫進度條,在我的 Js 代碼中我有一個百分比數字變量Puverg,如何更新進度條以具有與百分比數字相同的進度?var x = setInterval(function() {    var now = new Date().getTime();    var distance=countDownDate-now;    var vergangen=intervall-distance;    var Puverg=(vergangen/intervall)*100;    var Puebrig=100-Puverg;}, 1000);@import url("https://fonts.googleapis.com/css?family=Montserrat&display=swap");body{  font-family:Montserrat, sans-serif;  background: black;  color: white;}.container{  margin: 100px auto;  margin-top: 330px;  width: 400px;  text-align: center;  position: relative;}.progress2{  border-radius: 30px;  background-color: #fff;}.progress-bar2{  height: 18px;  border-radius: 30px;  transition: 0.4s linear;  transition-property: width,background-color;}.progress-moved .progress-bar2{  background-color:#f3c623;  animation: progress 5s infinite;}@keyframes progress{  0%{    width:0%;    background:#f9bcca;  }  100%{    width:100%;    background:#f3c623;    box-shadow: 0 0 40px #f3c623;  }}.icon{  color:#f3c623;  animation: icon 5s infinite;  background-color: transparent;  padding-right: 400px;  padding-bottom: 20px;}@keyframes icon{  0%{    opacity: .2;    text-shadow: 0 0 0 #f3c623;  }  100%{    opacity: 1;    text-shadow: 0 0 10px #f3c623;  }}.loader{  --p:0;  animation: p 5s steps(100) infinite;  counter-reset: p var(--p);  font-size: 2.1em;  position: absolute;  bottom: 45px;  left: 325px;  color:#f3c623;}.loader::after{  content: counter(p) "%";}@keyframes p{  90%,100%{    --p: 100;  }}
查看完整描述

1 回答

?
慕神8447489

TA貢獻1780條經驗 獲得超1個贊

我不確定哪個元素是你的progress bar。


假設您有兩個 div 來形成進度條。


<div id="container">

    <div id="progress"></div>

</div>

設置您自己的進度條寬度和高度。


#container {

    width: 'Set a width here';

    height: 'Set a height here';

    text-align: left;

}

#progress {

    width: 0;

    height: 100%;

}

不要忘記添加您自己的樣式。


progress只需隨著進度的變化更改 div 的寬度即可。設置寬度,就像10%您的進度一樣10%。但是您需要為進度條設置某些樣式。


var x = setInterval(function() {

    var now = new Date().getTime();

    var distance=countDownDate-now;

    var vergangen=intervall-distance;

    var Puverg=(vergangen/intervall)*100;

    var Puebrig=100-Puverg;


    /* Assuming Puebrig is the current percentage value */

    document.getElementById('progress').style.width = Puebrig+'%';


}, 1000);


查看完整回答
反對 回復 2023-10-20
  • 1 回答
  • 0 關注
  • 130 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號