CSS Note 2.3 animation

一、CSS

@charset "UTF-8";
div{
    margin: 10px;
    padding: 10px;
    width: 160px;
    height: 80px;
    background: chartreuse ;

}

@keyframes my {
    from {
        margin-left:50px ;
        background-color: green;
    }
    to{
        margin-left:300px ;
        background-color: blue;
    }
}
@keyframes you {
    0% {
        margin-left:50px ;
        background-color: yellow;
    }
    100%{
        margin-left:300px ;
        background-color: blue;
    }
}
#div5{
    animation-name:my ;
    animation-duration: 3s;/*动画持续时间*/
    animation-timing-function: ease-in-out;
    animation-delay: 1s;
    animation-iteration-count: 2;/*infinite不限次数*/
    animation-fill-mode: forwards;/*动画完成时停留在最后一帧,backwards在第一帧时应用,延时时停留在第一帧处,both是两种都应用*/
}
#div6{
    animation-name:you ;
    animation-duration: 3s;/*动画持续时间*/
    animation-timing-function: ease-in-out;
    animation-delay: 2s;
    animation-iteration-count: 2;/*infinite不限次数*/
    animation-direction:alternate ;/*轮流反向播放,默认值是normal*/
    animation-play-state: running;/*结合js使用可以定义动画暂停或者播放*/
    animation-fill-mode: both;
   /* 复合属性语法animation: name duration timing-function delay iteration-count direction;*/
}

二、效果展示

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值