是的,這是一個很好的方法。
這是同樣的想法更細化:
Live Demo
HTML:
<div class="pollBars">
<span class="t1" style="width: 10%">69</span>
<span class="t1" style="width: 20%">100</span>
<span class="t1" style="width: 70%">200</span>
<span class="t2" style="width: 90%">666</span>
<span class="t2" style="width: 120%">Over 9000!!</span>
</div>
CSS:
.pollBars {
width: 300px;
background: #ccc
}
.pollBars span {
display: block;
padding: 3px;
margin: 7px 0;
font: bold 14px/1 sans-serif;
-moz-border-radius: 4px;
border-radius: 4px;
text-shadow: 1px 1px 1px #444;
}
.t1 {
color: #fff;
border: 1px solid red;
background: #f85032; /* old browsers */
background: -moz-linear-gradient(top, #f85032 0%, #f16f5c 50%, #f6290c 51%, #f02f17 71%, #e73827 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f85032), color-stop(50%,#f16f5c), color-stop(51%,#f6290c), color-stop(71%,#f02f17), color-stop(100%,#e73827)); /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f85032', endColorstr='#e73827',GradientType=0); /* ie */
}
.t2 {
color: #fff;
border: 1px solid blue;
background: #6db3f2; /* old browsers */
background: -moz-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6db3f2), color-stop(50%,#54a3ee), color-stop(51%,#3690f0), color-stop(100%,#1e69de)); /* webkit */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#6db3f2', endColorstr='#1e69de',GradientType=0); /* ie */
}
哇,這是真棒!感謝您的額外造型! – chobo 2011-03-14 15:55:46
這是沒有問題:)我用它來快速獲得漸變:http://www.colorzilla.com/gradient-editor/ – thirtydot 2011-03-14 16:33:20