【发布时间】:2021-04-03 08:15:28
【问题描述】:
我正在尝试使用 Tailwind CSS,目前我正在尝试为背景图像设置动画。我尝试了不同的方法,但还没有弄清楚如何在从左到右的单方向上为背景图像设置动画。
这是我到目前为止所做的。
- 添加了自定义背景图片
- 添加了重复以填充该区域。
另外我想做的就是像动画一样展示它,让它感觉像是在移动。我已经用普通的 CSS 实现了它,但不能把它放在 Tailwind 中。
以下是用普通CSS实现的动画视频:https://youtu.be/Jx8fg2MdG3Y
以下是我目前实现的后台 Tailwind 游乐场:https://play.tailwindcss.com/jmoPHTdXAe
Tailwind 中当前实现的代码。
<div class="p-6 bg-gray-500 flex flex-col items-center min-h-screen justify-center bg-hero-pattern bg-repeat animate-ltr-linear-infinite">
<div class="text-white">
<h1 class="text-6xl">Some Text HERE</h1>
<h1 class="text-2xl">Background Not Animating</h1>
</div>
</div>
以下是我目前在 Tailwind 中尝试过的配置。
theme: {
extend:{
backgroundImage: theme => ({
'hero-pattern': "url('img/bg.png')"
}),
animation:{
'ltr-linear-infinite': 'normal 100s linear infinite'
}
}
}
以下是我用于重复的图像:
【问题讨论】:
标签: css tailwind-css