CSS Motion Path - CSS: Cascading Style Sheets 编辑
Experimental
This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Motion Path is a CSS module that allows authors to animate any graphical object along a custom path.
The idea is that when you want to animate an element moving along a path, you previously only had animating translation, position, etc. at your disposal, which wasn't ideal and only allowed for simple movements. With offset-path
you can define a specific path of any shape you want. You then animate it along that path by animating offset-distance
, and can choose to rotate it at any point using offset-rotate
.
Basic example
<div id="motion-demo"></div>
#motion-demo {
offset-path: path('M20,20 C20,100 200,0 200,100');
animation: move 3000ms infinite alternate ease-in-out;
width: 40px;
height: 40px;
background: cyan;
}
@keyframes move {
0% {
offset-distance: 0%;
}
100% {
offset-distance: 100%;
}
}
Reference
Properties
Specifications
Specification | Status | Comment |
---|---|---|
Motion Path Module Level 1 | Working Draft | Initial definition. |
Browser compatibility
offset property
BCD tables only load in the browser
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论