css - 带有移动背景的剪辑文本
问题描述
我找到了一种很好的方法来水平连续移动背景。我追求的效果是创造火焰的错觉,所以背景需要垂直移动。有没有办法做到这一点?我使用 Elementor 作为构建器。
我的css代码如下
.mask_text .elementor-widget-container {
background-clip: text;
-webkit-background-clip: text;
-moz-background-clip: text;
-o-background-clip: text;
animation: maskText 50s linear infinite;
-webkit-animation: maskText 50s linear infinite;
}
.mask_text .elementor-widget-container h2{
color:transparent !important;
}
@keyframes maskText{
from{ background-position: 0px center}
to{ background-position: 2000px center}
}
@-webkit-keyframes maskText{
from{ background-position: 0px center}
to{ background-position: 2000px center}
}
解决方案
要垂直移动,您需要更改的是向背景位置添加第二个值:
background-position: <horizontal> <vertical>
h1 {
margin: 0;
font-size: 100px;
color: transparent;
background: rgb(203,8,202);
background: linear-gradient(175deg, rgba(203,8,202,1) 0%, rgba(131,46,189,1) 35%, rgba(255,252,0,1) 100%);
background-clip: text;
-webkit-background-clip: text;
animation: maskText 50s linear infinite;
}
@keyframes maskText{
from{ background-position: center 2000px}
to{ background-position: center 0}
}
<h1>My Text</h1>
推荐阅读
- c++ - 如何在 C++ 中的向量中找到子字符串
- javascript - 如何使用 Javascript 将上传的音频转换为 Blob?
- javascript - 如何使用 Jest 和 Express 编写集成测试?
- python - 无法解析 modin 数据框中的一列 json 字符串(适用于 pandas)
- java - 读/写图像的问题
- r - 为什么形式函数在使用参数定义的函数上返回 NULL?
- r - R会话信息中的星号(*)符号
- python - 基本文件无法运行 -> 无法初始化设备 PRN
- javascript - 将谷歌标签管理器的标签片段放在 Angular 中的什么位置?
- php - 4张表之间的关系