Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何为选项卡设置渐变颜色?_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 如何为选项卡设置渐变颜色?

Javascript 如何为选项卡设置渐变颜色?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我必须设置特定选项卡的渐变色。它包含从第一个选项卡到最后一个选项卡的渐变色。我如何设置它。 为此,我使用了下面的代码 $(function() { $( "#tabs" ).tabs(); $('.gradient_me').each( function(index) { var color = 255-index*75; $(this).css('background', 'rgb('+color+', 0, 0)');

我必须设置特定选项卡的渐变色。它包含从第一个选项卡到最后一个选项卡的渐变色。我如何设置它。 为此,我使用了下面的代码

  $(function() {
    $( "#tabs" ).tabs();

      $('.gradient_me').each( function(index) {
          var color = 255-index*75;
          $(this).css('background', 'rgb('+color+', 0, 0)');
      });
  });
但问题是一个选项卡只包含一种颜色。我需要从第一个选项卡到最后一个选项卡的渐变颜色。我如何才能做到这一点?

简单

您所需要的只是一个线性渐变CSS规则。


演示:

但问题是一个选项卡只包含一种颜色。
您能详细说明一下吗。。我检查小提琴和制表符标题是否有3种不同color@bipen-我想要每个标签的渐变色。在演示中你可以看到标签是渐变色的。但是在标签中,不是渐变色。你想让我为你编码吗?我给了你做你想做的事的暗示。代码可以很容易地适应您的需要。要么自己做,要么换一份你能胜任的工作。
  $(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 +')');

      });
  });