首页 > 开发 > CSS > 正文

CSS的animation属性使用实例讲解

2024-07-11 08:29:45
字体:
来源:转载
供稿:网友

一、animation的语法
 
1、@keyframes——插入关键帧
 
(1)FormTo形式:

CSS Code复制内容到剪贴板
  1. @keyframes demo {         from {   
  2.        Properties:Properties value;         }   
  3.      Percentage {           Properties:Properties value;   
  4.      }         to {   
  5.        Properties:Properties value;         }   
  6. }  

 
 
(2)百分比的形式:
 

CSS Code复制内容到剪贴板
  1. @keyframes demo {          0% {   
  2.          Properties:Properties value;          }   
  3.       Percentage {             Properties:Properties value;   
  4.       }          100% {   
  5.          Properties:Properties value;          }   
  6. }  

 
 
2、animation-name——定义动画的名称

animation-name: none | “动画的名称”;
 
 
(1)动画的名称是由Keyframes创建的动画名,这里必须和创建的动画名保持一致。如果不一致,将不能实现任何动画效果
(2)none为默认值,当值为none时,将没有任何动画效果
 
3、animation-duration
 
animation-duration: time (s)
 
 
animation-duration是指定元素播放动画所持续的时间,取值为数值,单位为秒(s),其默认值为“0”。
 
4、animation-timing-function
 
animation-timing-function:ease(缓冲) || ease-in(加速) || ease-out(减速) || ease-in-out(先加速后减速) || linear(匀速) || cubic-bezier(自定义一个时间曲线)
 
 
animation-timing-function是用来指定动画的播放方式,具有以下六种变换方式:ease(缓冲);ease-in(加速);ease-out(减速);ease-in-out(先加速后减速);linear(匀速);cubic-bezier(自定义一个时间曲线)。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表