TailwindCSS:如何应用具有线性渐变的背景图像?

我想对我的背景图像应用线性渐变。在顺风配置文件中,我写了一个这样的自定义规则:

 theme: {
    extend: {
      backgroundImage: (theme) => ({
        'hero-pattern': "url('../src/images/icon-bg.jpg')",
  
      }),
    },
  },

有用。但是当我尝试应用线性渐变时,它不起作用。

为了应用线性梯度,我尝试过的是:

 theme: {
    extend: {
      backgroundImage: (theme) => ({
        
         'hero-pattern':
          "linear-gradient(to right bottom, rgba('#7ed56f',0.8), rgba('#28b485',0.8)), url('../src/images/icon-bg.jpg')",
      }),
    },
  },

但它没有用。

回答

不要使用函数。只是尝试作为一个实用程序

theme: {
    extend: {
      backgroundImage: {
         'hero-pattern': "linear-gradient(to right bottom, rgba('#7ed56f',0.8), rgba('#28b485',0.8)), url('../src/images/icon-bg.jpg')",
      },
    },
  },

这是一个工作示例https://play.tai​​lwindcss.com/uHp6pKIKEc


以上是TailwindCSS:如何应用具有线性渐变的背景图像?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>