-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
说说你对CSS动画的理解 #60
Comments
概述需求中常见的css3动画一般有补间动画(又叫“关键帧动画”)和逐帧动画两种,下面分别介绍:
animation的timing-function默认值为ease,它会在每个关键帧之间插入补间动画,所以动画效果是连贯性的。 除了ease、linear、cubic-bezier之类的过渡函数都会为其插入补间。 有些效果不需要补间,只需要关键帧之间的跳跃,这时应该使用steps过渡方式。 transition的主要api transition-property: height;
transition-duration: 1s;
transition-delay: 1s;
transition-timing-function: ease; transition的优点在于简单易用,但是它有几个很大的局限。 (1)transition需要事件触发,所以没法在网页加载时自动发生。 (2)transition是一次性的,不能重复发生,除非一再触发。 (3)transition只能定义开始状态和结束状态,不能定义中间状态,也就是说只有两个状态。 animation的主要apidiv:hover {
animation-name: rainbow;
animation-duration: 1s;
animation-timing-function: linear;
animation-delay: 1s;
animation-fill-mode:forwards;
animation-direction: normal;
animation-iteration-count: 3;
} keyframes的写法 @keyframes rainbow {
0% { background: #c00 }
50% { background: orange }
100% { background: yellowgreen }
} 另外一点需要注意的是,浏览器从一个状态向另一个状态过渡,是平滑过渡。steps函数可以实现分步过渡。 steps讲解:https://www.zhangxinxu.com/wordpress/2018/06/css3-animation-steps-step-start-end/ |
cubic-bezier可以参考这个 https://cubic-bezier.com/#25,.1,.25,1 |
No description provided.
The text was updated successfully, but these errors were encountered: