js+css 实现的简易进度条效果

<html>
<style type="text/css">
<!--
.td1 {
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: none;
border-top-color: #0000FF;
border-right-color: #0000FF;
border-bottom-color: #0000FF;
border-left-color: #0000FF;
}
.td2 {
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: solid;
border-right-style: none;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #0000FF;
border-right-color: #0000FF;
border-bottom-color: #0000FF;
border-left-color: #0000FF;
}
.tr1 {
border-top-style: solid;
border-right-style: none;
border-bottom-style: solid;
border-left-style: none;
border-top-color: #0000FF;
border-right-color: #0000FF;
border-bottom-color: #0000FF;
border-left-color: #0000FF;
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
}
.value {
background-color: #0000CC;
border-top-style: solid;
border-right-style: none;
border-bottom-style: solid;
border-left-style: none;
}
-->
</style>
<div id=d></div>
<input type=text id=p>
<input type=button οnclick="progressBar(d,p.value)" value="aaa">
</html>
<script type="text/javascript">
function progressBar(div,proValue){
//限定proValue大小
if(proValue<=0){
proValue=0;
}else if(proValue>=100){
proValue=100;
}
//获取 进度条表格
var t=document.getElementById("progressBar");
//不存在则新建
if(t == null || typeof(t)=="undefined"){
t =document.createElement("table");
t.width='100';
t.border='1';
t.cellpadding='0';
t.cellspacing='0';
t.id="progressBar";
//控制 表格的行
if(t.rows.length>0){
t.deleteRow(t.rows[0]);
}
//设置 表格内样式
var nr=t.insertRow();
nr.className="tr1";
for(i=0;i<100;i++){
var nc = nr.insertCell();
nc.width=1;
nc.innerHTML="&nbsp;"

}
}

//设置 进度值
for(i=0;i<proValue;i++) {
t.rows[0].cells[i].className="value";
}
for(i=proValue;i<100;i++){
if(i==0){
t.rows[0].cells[i].className="td2";
}else if(i==100){
t.rows[0].cells[i].className="td1";
}else{
t.rows[0].cells[i].className="tr1";
}
}
div.insertBefore(t);

}
</script>

js+css 实现的简易进度条效果

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值