跳动的球

效果动画.gif

animation

  • animation-name:动画名
  • animation-duration:动画执行时间
  • animation-interaction-count:1/2/.../infinate; 执行动画次数
  • animation-fill-mode:forwards; 终止状态
  • animation-direction:alternate; 动画结束后的执行方向
  • animation-timing-function:linear/ease/ease-in/ease-out/ease-in-out; 动画过渡效果
  • animation-delay:延时时间

代码

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>demo08_ball</title>
    <style>
    * {
        margin: 0px;
        padding: 0px;
    }

    section {
        width: 50%;
        height: 600px;
        margin: 10px auto;
        border: 1px solid silver;
        border-radius: 2px;
        text-align: center;
        position: relative;
    }

    div#ball {
        width: 200px;
        height: 200px;
        border: 0 none;
        background-image: radial-gradient(180px at center 10px, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));
        border-radius: 200px;
        position: absolute;
        left: 100px;
        /*动画名称*/
        animation-name: ball;
        /*动画时间*/
        animation-duration: 0.6s;
        /*终止状态*/
        animation-fill-mode: forwards;
        /*执行顺序:结束后反方向*/
        animation-direction: alternate;
        /*执行次数*/
        animation-iteration-count: infinite;
        /*过渡效果*/
        animation-timing-function: ease-in;
    }

    div#shadow {
        width: 160px;
        height: 30px;
        background-color: rgba(125, 125, 125, 0.6);
        border-radius: 160px / 30px;
        position: absolute;
        top: 300px;
        left: 130px;
        animation-name: shadow;
        animation-duration: 0.6s;
        animation-fill-mode: forwards;
        animation-direction: alternate;
        animation-iteration-count: infinite;
        animation-timing-function: ease-in;
    }

    @keyframes ball {
        0% {
            top: 20px;
        }
        100% {
            top: 115px;
        }
    }

    @keyframes shadow {
        0% {
            width: 160px;
            height: 30px;
            top: 300px;
            left: 120px;
        }
        100% {
            width: 0px;
            height: 0px;
            top: 315px;
            left: 200px;
        }
    }
    </style>
</head>

<body>
    <section>
        <div id="ball"></div>
        <div id="shadow"></div>
    </section>
</body>

</html>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    wzhiq896阅读 1,806评论 0 2
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    love2013阅读 2,342评论 0 11
  • 看了很多视频、文章,最后却通通忘记了,别人的知识依旧是别人的,自己却什么都没获得。此系列文章旨在加深自己的印象,因...
    DCbryant阅读 1,896评论 0 4
  • 在CSS3中,有一个新的属性可以用来做一些简单的动画效果,这就是animation,中文意思就是动画。 一、首先我...
    大春春阅读 3,335评论 1 9
  • 文/橙子欢 每天躺在床上,总会想写点什么,至于有没有人看,对现在的我来说,可能真的不重要了。想把这个系列当日记本来...
    橙子欢阅读 202评论 0 0