css3 动画 旋转移动

废话不多说,直接上代码
// css
.ellipse-rotate {
                width: 100px;
                height: 100px;
                position: absolute;
                -webkit-transition-property: -webkit-transform;
                -webkit-transition-duration: 1s;
                -moz-transition-property: -moz-transform;
                -moz-transition-duration: 1s;
                -webkit-animation: rotate 6s linear infinite;
                -moz-animation: rotate 6s linear infinite;
                animation: rotate 6s linear infinite;
                
            }
            .ellipse-move{
                -webkit-animation:move 10s infinite;
            animation: move 10s infinite;
                top: 80%;
                position: relative;
            }
            @-webkit-keyframes move {
                from {
                   top: 800px;
                }
                to {
                   top: 10px;
                }
            }
             @keyframes move {
                from {
                   top: 800px;
                }
                to {
                   top: 10px;
                }
            }
             @-moz-keyframes move {
                from {
                   top: 800px;
                }
                to {
                   top: 10px;
                }
            }
             @-o-keyframes move {
                from {
                   top: 800px;
                }
                to {
                   top: 10px;
                }
            }
            
            
            
            @-webkit-keyframes rotate {
                from {
                    -webkit-transform: rotate(0deg)
                }
                to {
                    -webkit-transform: rotate(360deg)
                }
            }
            
            @-moz-keyframes rotate {
                from {
                    -moz-transform: rotate(0deg)
                }
                to {
                    -moz-transform: rotate(359deg)
                }
            }
            
            @-o-keyframes rotate {
                from {
                    -o-transform: rotate(0deg)
                }
                to {
                    -o-transform: rotate(359deg)
                }
            }
            
            @keyframes rotate {
                from {
                    transform: rotate(0deg)
                }
                to {
                    transform: rotate(359deg)
                }
            }
            
            .horizontal {
                background-color: #f58f98;
                width: 100%;
                height: 50%;
                -moz-border-radius: 50%;
                -webkit-border-radius: 50%;
                border-radius: 50%;
                position: absolute;
                top: 25%;
            }
            
            .vertical {
                background-color: #f58f98;
                height: 100%;
                width: 50%;
                position: absolute;
                -moz-border-radius: 50%;
                -webkit-border-radius: 50%;
                border-radius: 50%;
                left: 25%;
            }
//html
<div class="ellipse-move">
            
            <div class="ellipse-rotate ">
                <div class=" horizontal">
    
                </div>
                <div class="vertical">
                </div>
            </div>
        </div>

原理也很简单,主要把CSS3 的keyframes规则运用灵活就行

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

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 172,976评论 25 708
  • CSS参考手册 一、初识CSS3 1.1 CSS是什么 CSS3在CSS2.1的基础上增加了很多强大的新功能。目前...
    没汁帅阅读 3,627评论 1 13
  • 年 就这样 隆重而来 悄然而去 孩子们小花炮 丰富的年夜大餐 一家人聚集在一起 开心快乐 热闹非凡 一年又一年 感...
    糖寶寶阅读 170评论 0 0
  • 我们每个人在现实生活中有二个身份,一个真我一个假我,线下的假我会 愤怒,生气,评判等让自己无喜悦和幸福感,向外求比...
    童鹭_阅读 163评论 0 0
  • 这名女子叫艾切维利娅,现年63岁。她从11岁就开始使用强生的婴儿爽身粉。当地媒体报道,艾切维利娅用爽身粉保持下体清...
    趣读书吧阅读 257评论 0 0