簡單!
所有你需要的是一個線性漸變CSS規則。
$(function() {
$("#tabs").tabs();
$('.gradient_me').each(function(index) {
var color = 'rgb(' + (255-index*75) + ', 0, 0)';
var color2 = 'rgb(' + (255-index*75 - 75) + ', 0, 0)';
$(this).css('background', '-moz-linear-gradient(left, '+color+', ' + color2 +')');
$(this).css('background', '-webkit-linear-gradient(left, '+color+', ' + color2 +')');
$(this).css('background', '-ms-linear-gradient(left, '+color+', ' + color2 +')');
$(this).css('background', '-o-linear-gradient(left, '+color+', ' + color2 +')');
$(this).css('background', 'linear-gradient(left, '+color+', ' + color2 +')');
});
});
演示:http://jsfiddle.net/5zfyU/8/
'但問題是一個選項卡只包含一個color.' u能闡述這個..我檢查了小提琴和標籤頭有3種不同的顏色 – bipen 2013-04-29 05:28:24
@ bipen,我想漸變顏色爲每個選項卡。在演示中,您可以看到選項卡漸變。但在選項卡內,它不是 – Niths 2013-04-29 05:30:34