首页 > Web开发 > 详细

CSS+DIV进度条

时间:2015-03-22 16:15:20      阅读:192      评论:0      收藏:0      [点我收藏+]
<style type="text/css">
.Bar { position: relative; width: 200px;    /* 宽度 */ border: 1px solid #B1D632; padding: 1px; }
.Bar div { display: block; position: relative; background:#00F;/* 进度条背景颜色 */ color: #333333; 
      height
: 20px; /* 高度 */ line-height: 20px; /* 必须和高度一致,文本才能垂直居中 */ } .Bar div span{ position: absolute; width: 200px; /* 宽度 */ text-align: center; font-weight: bold; } </style>
<div class="Bar">
    <div style="width: 50%;">
        <span>50%</span>
    </div>
</div>
  //此方法用于计算百分比
  public String getPercent(int x,int total){ if(x==0&&total!=0){ return "0"; }else if(x==0&&total==0){ return "100%"; } String result="";//接受百分比的值 double x_double=x*1.0; double tempresult=x_double/total; //保留到小数点后几位 DecimalFormat df = new DecimalFormat("0.00%"); //##.00% 百分比格式,后面不足2位的用0补齐 result= df.format(tempresult); //注释掉的也是一种方法 //NumberFormat nf = NumberFormat.getPercentInstance(); //nf.setMinimumFractionDigits( 2 ); //result=nf.format(tempresult);      return result; }

CSS+DIV进度条

原文:http://www.cnblogs.com/hehaiyang/p/4357418.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!