JavaScript数学和CSS百分比
我有一个进度的DIV容器和一个XHR请求,将Base64图像发布到服务器上。
进度指标div的外观如下:
<style>
.progresscover {
background: #eee;
width:100%;
height: 3px;
position: relative;
text-align: left;
}
.progress{
width:0%;
height:100%;
background: purple;
position:absolute:
left:0px;
top:0px;
bottom:0px;
}
</style>
<div class="progresscover"><div class="progress"></div></div>
从XHR请求中,我得到以下值 加载:102533,总计:703227 负载显然会变化直到其
总数等于总数。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
I have a progress div container and an xhr request posting base64 images to the server.
The progress indicator div looks as follows:
<style>
.progresscover {
background: #eee;
width:100%;
height: 3px;
position: relative;
text-align: left;
}
.progress{
width:0%;
height:100%;
background: purple;
position:absolute:
left:0px;
top:0px;
bottom:0px;
}
</style>
<div class="progresscover"><div class="progress"></div></div>
from the XHR request i get following values
loaded: 102533, total: 703227
The loaded obviously changes till its equal to the total..
what is the math to increase the width of the "progress" bar incrementally in percentages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
像这样-Parseint((加载 /总计 * 100),10) +'%');
its like this -- parseInt( (loaded / total * 100), 10) + '%');
您是否想实现这样的目标?
Are you trying to achieve something like this?