欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Animations动画和Keyframes关键帧

程序员文章站 2024-03-24 22:22:46
...
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    body {
        display: flex;              /* 使用Flex布局 */
        justify-content: center;    /* 水平居中 */
    }
    .ball {
        width: 100px;
        height: 100px;
        border-radius: 50%;         /* 把正方形变成圆形*/
        background-color: #FF5722;  /* 设置颜色为橙色*/
        animation: bounce 0.5s cubic-bezier(.5,0.05,1,.5);
        animation-direction: alternate;  //alternate(2,4,6)反向动画
        animation-iteration-count: infinite;
    }
    @keyframes bounce {
        from { transform: translate3d(0, 0, 0);     }
        to   { transform: translate3d(0, 200px, 0) rotateX(45deg); }
    }
</style>
<body>
<div class="ball"></div>
<script>
</script>
</body>
</html>