用过渡改变渐变背景

时间:2021-07-14 15:46:01

标签: css reactjs

我有一个渐变背景。

我根据条件改变背景。

我想通过过渡改变背景颜色。

如果我使用渐变,transition 有效,否则无效。

此转换不起作用:

style={{
  background:
    activeLineId === lineIds[0] ? 'linear-gradient(to right, #F29E4C, Linen)' :
      activeLineId === lineIds[1] ? 'linear-gradient(to right, #2DAFD6, Linen)' :
        'linear-gradient(to right, #AFFC41, Linen)',
        transition: "all 0.8s ease",
        WebkitTransition: "all 0.8s ease",
        MozTransition:"all 0.8s ease"   
}}>

此过渡有效:

style={{
  background:
    activeLineId === lineIds[0] ? 'red' :
      activeLineId === lineIds[1] ? 'blue' :
        'black',
        transition: "all 0.8s ease",
        WebkitTransition: "all 0.8s ease",
        MozTransition:"all 0.8s ease"   
}}>

如何通过过渡更改渐变背景?

0 个答案:

没有答案