2010-08-16 40 views

回答

1

我會用兩個嵌套的容器和做它在某種程度上是這樣的:

#outer { 
    background: url('empty.png') top left repeat-x #666666; 
    position: relative; 
    height: 16px; /* set this to the height of the image */ 
    width: 80px; /* set this to a multiple of the image’s width */ 
} 

#inner { 
    background: url('filled.png') top left repeat-x #999900; 
    position: absolute; 
    top: 0; 
    left: 0; 
    height: 16px; /* same as above */ 
} 

根據需要設置通過行內CSS內部容器上的width屬性:

style='width: 32px;' 
style='width: 64px;' 

(一點也沒有」不一定必須是一幅圖像寬度的倍數。)

獎勵:如果圖片不使用透明度,CSS的備用背景顏色將組成如果圖像無法加載,則爲百分比欄。