CSS动画属性及其实例

一.CSS常见动画属性

(1)

animation 属性是一个简写属性,用于设置六个动画属性:

  • animation-name
  • animation-duration
  • animation-timing-function
  • animation-delay
  • animation-iteration-count
  • animation-direction

(2)transition :过渡效果的 CSS 属性的名称  完成过渡效果需要多少秒或毫秒  速度效果的速度曲线  过渡效果何时开始;

(3)transform: 改变元素的大小、位置;

二.实例

代码:

<!DOCTYPE html>

<html lang="en">

 

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>动画</title>

    <link rel="stylesheet" href="动画.css">

    <style>

        body {

    margin: 0px;

    padding: 0px;

}

 

#Background {

    width: 1000px;

    height: 1000px;

    background-color: aqua;

}

 

#box {

    width: 100px;

    height: 100px;

    animation: move 4s;

    animation-timing-function: linear;

    animation-iteration-count: infinite;

    animation-direction: alternate;

}

 

@keyframes move {

    0% {

        border-radius: 50px;

        background-color: rgb(238, 42, 42);

        transform: translate(0px, 500px);

    }

    40% {

        width: 100px;

        height: 100px;

        border-radius: 10px;

        background-color: rgb(238, 42, 42);

        transform: translate(400px, 500px);

    }

    45% {

        width: 100px;

        height: 100px;

        background-color: rgb(238, 42, 42);

        transform: translate(450px, 500px);

    }

    50% {

        width: 100px;

        height: 100px;

        background-color: rgb(238, 42, 42);

        transform: translate(500px, 500px);

    }

    55% {

        width: 100px;

        height: 100px;

        background-color: rgb(204, 238, 12);

        transform: translate(550px, 500px);

    }

    60% {

        width: 100px;

        height: 100px;

        border-radius: 10px;

        background-color: rgb(204, 238, 12);

        transform: translate(600px, 500px);

    }

    100% {

        border-radius: 50px;

        background-color: rgb(204, 238, 12);

        transform: translate(900px, 500px);

    }

}

    </style>

</head>

 

<body>

 

    <div id="Background">

        <div id="box"></div>

    </div>

 

</body>

 

</html>

三.动画效果截图显示

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值