CSS3动画

CSS3动画

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            width: 100px;
            height: 100px;
            border: 1px solid #000;
            border-radius: 50%;
            background-color: red;
            position: relative;
            left: 0;
            top: 0;
            animation-name: zql;
            /*规定动画的名称*/
            animation-duration: 10s;
            /*规定动画在多久内做完*/
            animation-timing-function: ease;
            /*规定动画运行样式*/
            animation-delay: 1s;
            /*规定动画延迟时间*/
            animation-iteration-count: infinite;
            /*规定动画循环次数*/
            animation-direction: normal;
            /*规定动画是否逆向播放*/
            animation-fill-mode: none;
            /*规定动画执行完之后的位置*/
            animation-fill-mode: none;
            /*规定动画等待和执行完毕时的样式*/
            /*四个值
            1:none;默认为none,不改变
            2:forwards让动画在执行完毕后停留在动画最后一帧
            3:backwards,让动画在等待时显示动画的第一帧;
            4:both forwards和backwards的结合
            */
        }

        div {
            animation: zql 10s ease 1s infinite normal none;
        }

        div:hover {
            animation-play-state: paused;
            /*规定是否暂停动画*/
        }
        div>span{
            display: block;
            width: 50px;
            height: 50px;
            border: 1px solid #000;
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            margin: auto;
            background-color: gold;
        }

        @keyframes zql {
            form {
                left: 0;
                top: 0;
                background-color: red;
            }
            /*从这里开始*/
            to {
                left: 100px;
                top: 100px;
                background-color: yellow;
            }
            /*到这里结束*/
        }

        @keyframes zql {
            0% {
                width: 100px;
                height: 100px;
                left: 0;
                top: 0;
                background-color: red;
                transform: rotate(0deg);
            }
            25% {
                width: 200px;
                height: 200px;
                left: 400px;
                top: 0;
                background-color: yellow;
                transform: rotate(90deg);
            }
            50% {
                width: 100px;
                height: 100px;
                left: 400px;
                top: 400px;
                background-color: pink;
                transform: rotate(180deg);
            }
            75% {
                width: 200px;
                height: 200px;
                left: 0;
                top: 400px;
                background-color: #000000;
                transform: rotate(270deg);
            }
            100% {
                width: 100px;
                height: 100px;
                left: 0;
                top: 0;
                background-color: red;
                transform: rotate(360deg);
            }
        }
    </style>
</head>
<body>
<div>
    <span></span>
</div>
</body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 在CSS3中,动画效果使用animation属性来实现。animation属性和transition属性功能是相同...
    挥剑斩浮云阅读 744评论 0 2
  • CSS3动画应用很广,尤其是在H5项目中,炫酷的交互效果可以给产品带来更好的体验,更能吸引用户。然而在应用的时候,...
    UIleader阅读 2,309评论 0 7
  • 通过 CSS3,我们能够创建动画,这可以在许多网页中取代动画图片、Flash 动画以及 JavaScript。 什...
    LorenSLJ阅读 680评论 0 0
  • 纯CSS3人物行走动画 逼真炫酷CSS3动画 CSS3实在是太强大了,今天分享的CSS3动画非常神奇,它可以模拟人...
    wblearn阅读 2,351评论 1 31
  • 今天,妈妈让我练速读。我嘴上说着:“我马上就去。”但是心里却是那么的不情愿。 我打开了电脑,找到了速...
    肖博涵xbh阅读 135评论 0 0

友情链接更多精彩内容