尾风中不透明的背景图像 [英] Background Image with opacity in tailwindcss
本文介绍了尾风中不透明的背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试重新创建一个从普通的css到tawincss的项目。但我尝试了很多选择,都失败了。
这是css代码:
header {
background: linear-gradient(rgba(135, 80, 156, 0.9), rgba(135, 80, 156, 0.9)), url(img/hero-bg.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
background-attachment: fixed;
position: relative;
}
任何人可以将此代码转换为等效的TailWincss代码吗?
推荐答案
您有几个选项:
最简单的方法是在style属性上设置图像,毕竟这是非常定制的样式:
<header
class="relative bg-fixed bg-center bg-cover bg-no-repeat"
style="background-image:linear-gradient(rgba(135, 80, 156, 0.9), rgba(135, 80, 156, 0.9)), url(img/hero-bg.jpg)">
</header>
第二个选项是继续使用现在的样式表,但仅用于背景图像:
header {
background-image:linear-gradient(rgba(135, 80, 156, 0.9), rgba(135, 80, 156, 0.9)), url(img/hero-bg.jpg)
}
<header class="relative bg-fixed bg-center bg-cover bg-no-repeat">
</header>
最后,您可以创建一个插件,您可以在其中动态发送颜色,图像作为参数和顺风将为您生成这些类。这比较复杂,但文档确实很有帮助:https://tailwindcss.com/docs/plugins#app
如果你问我,我会选择第一个选项😃
以下是工作演示和教程:https://bleext.com/post/creating-a-hero-header-with-a-fixed-image
这篇关于尾风中不透明的背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文