html - 如何在css中停止文本动画
问题描述
我的动画没有在文本末尾结束,我该怎么做才能让它在显示一些文本后停止。
h2 {
justify-content: center;
position: relative;
font-size: 14vw;
color: #ffffff;
-webkit-text-stroke: 0.3vw #ffffff;
text-transform: uppercase;
}
h2::before {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
color: #01fe87;
-webkit-text-stroke: 0vw #ffffff;
border-right: 2px solid #ffffff;
overflow: hidden;
animation: animate 6s linear;
}
@keyframes animate {
0%,
100% {
width: 0;
}
70%,
90% {
width: 100%;
}
}
<h2 data-text="Hi..">Hi..</h2>
我是初学者所以很多东西都不知道
解决方案
h2 {
justify-content: center;
position: relative;
font-size: 14vw;
color: #ffffff;
-webkit-text-stroke: 0.3vw #ffffff;
text-transform: uppercase;
}
h2::before {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
color: #01fe87;
-webkit-text-stroke: 0vw #ffffff;
border-right: 2px solid #ffffff;
overflow: hidden;
animation: animate 6s linear;
}
@keyframes animate {
0%,
100% {
width: 0;
}
70%,
90% {
width: 100%;
}
}
<h2 data-text="Hi Atih <3">Hi Atih <3</h2>
推荐阅读
- algorithm - 如何找到从所有可能的子数组中选择的最小元素和次小元素的最大和
- javascript - bit.dev 相当于分叉一个 repo 并提交一个 PR 是什么?
- reactjs - 反应性能优化
- r - 谷歌地形视图和卫星视图在 R 中使用 GGMAP 使用 Zoom 和 ggsn :: scalebar
- c++ - clion中llvm c++ api的语法高亮
- centos7 - 无法在 Centos7 中启动 node_exporter.service 以进行 Prometheus 监控 - 无法执行操作:错误消息
- python - 将十六进制格式转换为字符串
- css - 如何在 bootstap-vue 切换按钮中更改背景颜色
- android - 如何在 API 完成时暂停 Kotlin 中的执行
- angular - 如何使用 *ngFor 在 angular 8 中的特定字符之后从字符串中删除特定文本?