css3动画

CSS动画分为Transition功能和Animations功能

Transition功能支持从一个属性值平滑过渡到另一个属性值:在样式代码中,如果使用Firefox浏览器,需要写成“-moz-transition”的形式;如果使用Opera浏览器,需要写成“-o-transition”形式;如果使用的是Safari或者是Chrome浏览器,需要写成“-webkit-transtion”形式。

transtion属性使用方法:transition:property duration timing-function

property表示要进行平滑过渡的属性,duration完成过渡的时间,timing-function表示通过什么方法完成过渡

同时过渡多个属性:property1 duration1 timing-function1,property2 duration2 timing-function2

不同属性之间用“,”隔开

Animations功能与Transitions功能相同,只是可以实现更复杂的动画。

Animations使用示例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        div{
            background-color: red;
        }
        @-webkit-keyframes myPlay {
            0%{
                background-color:red ;
            }
            50%{
                background-color:green;
            }
            100%{
                background-color:red;
            }
        }
        div:hover{
            -webkit-animation-name:myPlay ;
            -webkit-animation-duration:3s;
            -webkit-animation-timing-function: linear ;
        }
    </style>
</head>
<body>
    <div>演示</div>
</body>
</html>
也可以实现多个属性值同时改变,例子如下:

div{
    background-color: red;
    width:200px;
    height: 200px;
}
@-webkit-keyframes myPlay {
    0%{
        background-color:red ;
        width: 200px;
    }
    50%{
        background-color:green;
        width:300px;
    }
    100%{
        background-color:red;
        width: 200px;
    }
}
div:hover{
    -webkit-animation-name:myPlay ;
    -webkit-animation-duration:3s;
    -webkit-animation-timing-function: linear ;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值