CSS3的过渡 transition

这里只考虑 chrome 的兼容。

transition.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Transition</title>
    <style>
        #block {
            width: 400px;
            height: 300px;
            background-color: #69C;
            margin: 0 auto;

            transition: background-color 1s, width 0.5s ease-out;
            -webkit-transition: background-color 1s, width 0.5s ease-out;
        }
        #block:hover {
            background-color: red;
            width: 600px;
        }
    </style>
</head>
<body>
    <div id="block">

    </div>
</body>
</html>

transitionDemo.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>TransitionDemo</title>
    <style>
        #wrapper {
            width: 1024px;
            margin: 0 auto;
        }
        .progress-bar-bg {
            width: 960px;
            /*background-color: aliceblue;*/
            background-color: lightyellow;
        }
        .progress-bar {
            height: 40px;
            width: 40px;
            background-color: #69C;

            border: 1px solid lightyellow;
            border-radius: 5px;
        }
        .progress-bar:hover {
            width: 960px;
        }

        #bar1 {
            -webkit-transition: width 5s linear;
            /*-webkit-transition: width 5s steps(6, end);*/
            /*-webkit-transition: width 5s step-start;*/
        }
        #bar2 {
            -webkit-transition: width 5s ease;
        }
        #bar3 {
            -webkit-transition: width 5s ease-in;
        }
        #bar4 {
            -webkit-transition: width 5s ease-out;
        }
        #bar5 {
            -webkit-transition: width 5s ease-in-out;
        }
    </style>
</head>
<body>
<div id="wrapper">
    <p>linear</p>
    <div class="progress-bar-bg">
        <div class="progress-bar" id="bar1"></div>
    </div>

    <p>ease</p>
    <div class="progress-bar" id="bar2"></div>

    <p>ease-in</p>
    <div class="progress-bar" id="bar3"></div>

    <p>ease-out</p>
    <div class="progress-bar" id="bar4"></div>

    <p>ease-in-out</p>
    <div class="progress-bar" id="bar5"></div>
</div>
</body>
</html>
运行结果如下:


结果分析:鼠标移动上去后,会发生过渡动画。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值