当前位置:   article > 正文

css3动画曲线运动

css3曲线动画
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box{width: 50px;height: 120px;margin-top: 500px;margin-left: 500px}
        .box2{width: 50px;height: 120px;background: black;}
        .box{ animation: top1 1s ease-out forwards}
        .box2{ animation:  right1 1s ease-in forwards ;}

       @keyframes top1 {
          0%{transform: translateY(0px) ;}
          100%{transform: translateY( -200px) ;}
      }
        @keyframes right1 {
            0%{transform: translateX(0px) rotate(0deg);}
            100%{transform: translateX(200px) rotate(90deg);}
        }
    </style>
</head>
<body>
<div class="box">
    <div class="box2"></div>
</div>
</body>
</html>

 第一种写法通过两个盒子执行不同动画,第二种通过一个盒子执行两个动画。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    .box{
        text-align: center;
        width: 50px;
        height: 80px;
        border-radius: 10px;
        background: black;
        position: absolute;
        animation:bimg1 2s ease-out forwards,bimg2 2s ease-in forwards;
        /*ease-out ,和ease-in 顺序不能反*/
    }
    .main{width: 30px;height: 10px;background: whitesmoke;margin: 85% auto;border-radius: 2px}
    @keyframes bimg1 {
        0% {top: 0;transform: rotate(0deg)}
        100% {top: 200px;transform: rotate(-90deg)}
    }
    @keyframes bimg2 {
        0%  {left: 0;}
        100% {left: 400px;}
    }

</style>
<body>
<div class="box">
    <div class="main"></div>
</div>
</body>
</html>

 

转载于:https://www.cnblogs.com/xiaobaibubai/p/7060189.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/266186
推荐阅读
相关标签
  

闽ICP备14008679号