css3动画功能

本文深入讲解了CSS3中transition和animation的功能及用法,包括过渡效果的设置、关键帧动画的创建等,提供了实例帮助理解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

css3动画功能

transition
用法:
-moz-transition:
-webkit-transition:
-o-transition:

transition:property duration timing-function delay
transition-property
属性规定应用过渡效果的css属性的名称
none没有属性获得过渡效果
all所有属性都将获得过渡效果
property定义应用过渡效果的css属性名称列表,列表以逗号分隔

transition-duration
变换延续的时间

transition-timing-function
在延续的时间段,变换的速率变化
ease速率变慢
linear匀速
ease-in加速
ease-out减速
ease-in-out先加速后减速
cubic-bezier(n,n,n,n)

transition-delay
延迟时间

    div{
        width: 100px;
        height: 100px;
        background-color: red;
        transition: all 5s linear 0;
    }
    div:hover{
       background-color:  yellow; 
       
    }

animations
用法:
@-webkit-keyframes:关键帧合合集名称(创建关键帧的代码)
0%-100%{
$关键帧中的样式
}

元素{
-webkit-animations-name:mycolor;
}

       div{
            height: 20px;
            background-color: red;
        }
        @keyframes mycolor{
            0%{
                background-color: red;
                width: 0;
                transform: rotate(0deg);
                transform: translate(0px,0px);
            }
            10%{
                background-color: yellow;
                width:20px;
                transform: rotate(10deg);
                transform: translate(100px,0px);
            }
            20%{
                background-color: green;
                width: 50px;
                transform: rotate(30deg);
            }
            80%{
                background-color: black;
                width: 150px;
                transform: rotate(100deg);
            }
            100%{
                background-color: white;
                width: 200px;
                transform: rotate(180deg);
            }
        }
        div{
            animation-name: mycolor;
            animation-duration: 5s;
            animation-timing-function: linear;
            animation-iteration-count: infinite;
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

uncle_Huang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值