定义@keyframes bounce设置transform位移,将animation绑定到文字元素并设为无限循环,通过调整关键帧时间、位移值和缓动函数控制跳动节奏与幅度,实现自然的文字跳动效果。

要使用 CSS 的 animation 制作文字跳动效果,核心是结合 @keyframes 定义动画帧,并通过 transform 属性控制文字的上下位移,模拟“跳动”感。
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(-10px);
}
60% {
transform: translateY(-5px);
}
}
.bounce-text {
display: inline-block;
font-size: 24px;
color: #333;
animation: bounce 0.6s ease infinite;
}
<span class="bounce-text">跳动的文字</span>
基本上就这些。通过控制 keyframes 和 animation 参数,你可以轻松实现各种风格的文字跳动效果,比如心跳式、弹球式或呼吸式跳动。以上就是在css中如何用animation制作文字跳动效果的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号