css3过渡动画

css3过渡动画——transition属性

- 语法

```css

transition: transition-proterty transition-duration transition-timing-function transition-delay;

transition: css样式  动画的执行时间  速度类型  动画的延迟时间;

 多个css属性用逗号隔开

 transition: transform 2s, background-color 2s;

注意:谁发生了属性的改变 就加在谁身上

```

- 属性

  1、transition-proterty

  - css样式:参与过渡的css属性名称|all表示所有属性

  2、transition-duration

  - 动画执行时间:默认0s,s|ms(毫秒)   1s=1000ms

  3、transition-timing-function

  - 速度类型

    1.linear 相同的速度从开始到结束,也就是匀速

    2.ease  默认值 慢速度开始--速度变快--慢速度结束

    3.ease-in 慢速度开始的过渡效果,也就是以低速度开始

    4.ease-out 慢速度结束的过渡效果,也就是以低速结束

    5.ease-in-out 以慢速度开始和结束的过渡效果

  4、transition-delay

  - 延迟时间:默认0s,单位s|ms

> 注意:必须设置transition-duration属性,否则执行时间为0,不会产生过渡效果

```html

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

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

    <title>Document</title>

    <style>

        * {

            margin: 0;

            padding: 0;

        }

        .warp {

            width: 400px;

            height: 400px;

            background-color: pink;

        }

        .box {

            width: 200px;

            height: 200px;

            background-color: tomato;

            /* 参与过渡的css属性名称 */

            transition-property: width, height, background-color;

            /* 动画执行时间 */

            transition-duration: 2s;

            /* 速度类型 */

            transition-timing-function: linear;

            /* 延迟时间 */

            transition-delay: 2s;

            /* 复合写法 */

            transition: width 2s 2s, height 2s 2s, background-color 2s 2s;

            /* transition: all 1s linear 2s; */

            transition: 2s linear 2s;

        }

        .warp:hover .box {

            width: 300px;

            height: 300px;

            background-color: blue;

        }

    </style>

</head>

<body>

    <div class="warp">

        <div class="box"></div>

    </div>

</body>

</html>

```

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值