css - 背景彩虹动画不起作用为什么?
问题描述
.rainbow {
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
animation: change 10s ease-in-out infinite;
}
@keyframes change {
0% {
background-position: 0 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0 50%;
}
}
如果我将彩虹类添加到 div 容器中,彩虹不起作用,为什么!?
解决方案
它不起作用,因为 background-position 将与背景图像一起使用,但不适用于颜色。
Js小提琴-> https://jsfiddle.net/MahuaSarkar/dxLsoqp0/
尝试这个:
<div class="rainbow ">
<div>
Lorem ipsum is placeholder text commonly used in the graphic, print, and publishing industries for previewing layouts and visual mockups.
</div>
</div>
<style>
.rainbow {
background-image: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
animation: change 1s ease-in-out infinite;
}
@keyframes change {
0% {
background: linear-gradient(-45deg, #23d5ab, #ee7752, #e73c7e, #23a6d5);
}
50% {
background: linear-gradient(-45deg, #23a6d5, #23d5ab, #ee7752, #e73c7e);
}
100% {
background: linear-gradient(-45deg, #e73c7e, #23a6d5, #23d5ab, #ee7752);
}
}
</style>
希望有帮助!!
推荐阅读
- javascript - 当我有 2 个 jquery 库时,文档准备不工作
- c++ - Windows 10 中代码块 mingw 和 glfw 的 cmake 错误
- datetime - gnuplot 与 x 轴上的时间
- android - 颤振项目错误:失败:构建失败并出现异常
- c# - 使用位图和 ARGB 扫描图像中的红色 - C#
- cassandra - Cassandra:创建分区表而不在主键中包含分区列名
- reactjs - 用笑话和酶进行稳健的测试
- json - 如何在机器人框架中使用 json 中的另一个值提取一个值
- javascript - 如何将 id 从一张表转移到另一张表?
- c# - 更改 DropDownList Combobox 的背景