CSS+DIVプログレスバー
5194 ワード
<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;
}