有趣的CSS弹跳动画

绪论

看到一个有趣的css弹跳动画,转一下。

正文

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>有趣的CSS弹跳动画</title>
    <script src="js/jquery-2.2.4.min.js"></script>
    <style>
        .box {
            position: relative;
        }

        .box:before {
            content: '';
            position: absolute;
            z-index: 2;
            top: 60px;
            left: 50px;
            width: 50px;
            height: 50px;
            background: #c00;
            border-radius: 2px;
            transform: rotate(45deg);
        }

        .box:after {
            content: '';
            position: absolute;
            z-index: 1;
            top: 128px;
            left: 52px;
            width: 44px;
            height: 3px;
            background: #eaeaea;
            border-radius: 100%;
        }

        .box:before {
            content: '';
            position: absolute;
            z-index: 2;
            top: 60px;
            left: 50px;
            width: 50px;
            height: 50px;
            background: #c00;
            border-radius: 2px;
            transform: rotate(45deg);
            -webkit-animation: box .8s infinite;
        }

        @-webkit-keyframes box {
            0% {
                top: 50px;
            }

            20% {
                border-radius: 2px;
                /*从20%的地方才开始变形*/
            }

            50% {
                top: 80px;
                border-bottom-right-radius: 25px;
            }

            80% {
                border-radius: 2px;
                /*到80%的地方恢复原状*/
            }

            100% {
                top: 50px;
            }
        }

        .box:after {
            content: '';
            position: absolute;
            z-index: 1;
            top: 128px;
            left: 52px;
            width: 44px;
            height: 3px;
            background: #eaeaea;
            border-radius: 100%;
            -webkit-animation: shadow .8s infinite;
        }

        @-webkit-keyframes shadow {

            0%,
            100% {
                left: 54px;
                width: 40px;
                background: #eaeaea;
            }

            50% {
                top: 126px;
                left: 50px;
                /*让阴影保持在原位*/
                width: 50px;
                height: 7px;
                background: #eee;
            }
        }

        @-webkit-keyframes box {
            0% {
                top: 50px;
                transform: rotate(90deg);
                /**/
            }

            20% {
                border-radius: 2px;
            }

            50% {
                top: 80px;
                transform: rotate(45deg);
                border-bottom-right-radius: 25px;
            }

            80% {
                border-radius: 2px;
            }

            100% {
                top: 50px;
                transform: rotate(0deg);
            }
        }
    </style>
</head>

<body>
    <div class="box"></div>
</body>
<script>
    $(document).ready(function () {

    });

</script>

</html>

结果如图

在这里插入图片描述
(若有什么错误,请留言指正,3Q)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值