我想对我的背景图像应用一个线性渐变。在顺风配置文件中,我编写了一个自定义规则,如下所示:
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')",
}),
},
},但它并没有起作用。
发布于 2021-05-03 22:58:47
问题是你在rgba中给出了十六进制的颜色代码,这就是颜色不被应用的原因。
你必须给出rgba color code而不是hex color code
注意: rgba内的十六进制颜色代码仅由scss支持
发布于 2021-05-01 19:20:57
不要使用函数。试着把它当作一个实用工具
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.tailwindcss.com/uHp6pKIKEc示例
https://stackoverflow.com/questions/67344478
复制相似问题