motion-path
<svg width="500" height="200"> <path id="myPath" d="M50,100 C150,50 350,150 450,100" fill="none" stroke="none"/> </svg>
d
fill="none" stroke="none"
<span>
<p>
<span class="text">Hello, Motion Path!</span>
motion-path
offset-path
motion-offset
.text { position: absolute; /* 重要:需要绝对定位 */ font-size: 24px; color: blue; motion-path: path('M50,100 C150,50 350,150 450,100'); /* 使用SVG路径数据 */ /* 或者使用 motion-path: url(#myPath); 如果SVG在HTML中 */ offset-path: path('M50,100 C150,50 350,150 450,100'); /* 兼容旧浏览器 */ motion-offset: 0%; /* 初始位置 */ animation: moveText 5s linear infinite; } @keyframes moveText { to { motion-offset: 100%; offset-distance: 100%; /* 兼容旧浏览器 */ } }
position: absolute
motion-path
motion-path: path('...')
motion-path: url(#myPath)
url()
motion-offset: 0%
motion-offset: 100%
animation
offset-distance
animation
motion-rotation
motion-rotation
auto
reverse
.text { motion-rotation: auto; /* 或 motion-rotation: reverse; */ }
animation-timing-function
ease-in-out
transform: translateZ(0);
backface-visibility: hidden;
requestAnimationFrame
motion-path
offset-path
offset-distance
motion-path
motion-path
motion-path
motion-path
motion-path
motion-path
<div>
@@##@@
<div class="element"></div>
.element { position: absolute; width: 50px; height: 50px; background-color: red; border-radius: 50%; motion-path: path('M100,100 m -75, 0 a 75,75 0 1,0 150,0 a 75,75 0 1,0 -150,0'); /* 圆形路径 */ motion-offset: 0%; animation: rotate 5s linear infinite; } @keyframes rotate { to { motion-offset: 100%; } }
以上就是CSS如何实现文字路径动画?motion-path新标准应用的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号