zoukankan      html  css  js  c++  java
  • CSS3:动画大全

    和过渡的区别


    页面不用明显js调用;
       过渡:必须有:hover visited 等伪类调用。(本质还是事件驱动)
       动画:页面加载上就可以。
    页面有js调用:
    

    7个参数,*为可选

    animation-name   
    animation-duration  执行时长
    *animation-timing-function  和过渡一样http://www.cnblogs.com/leee/p/5481693.html
    *animation-delay   延迟多少时间 ms s
    *animation-iteration-count  循环次数默认为 1 (反方向也算一次)。无限循环infinite。 
    *animation-direction 偶数反向播放alternate 正向方向 normal
    *animation-fill-mode 回撤位置none、forwards(保持动画最终)、backwards(保持动画开始) 或 both(同时2中状态,没用过)
    

    播放 暂停 属性


    animation-play-state 播放状态( running 播放 和paused 暂停 )
    

    缺点:


    1,写起来复杂。至少3个针对浏览器的animation+至少3个针对浏览器的#keyframe,
    2没法动态改变目标点位置(animation-fill-mode)
    

    关键帧:


    数字:0%、25%、100%等
    字符:from(0%)、to(100%)
    

    JS结合


    参考http://www.cnblogs.com/leee/p/5481693.html

    obj.addEventListener('webkitAnimationEnd', function (){}, false); webkit
    obj.addEventListener('AnimationEnd', function (){}, false); firfox
    

    例子

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <style>
    @-webkit-keyframes move
    {
    	0%{
    		100px;
    	}
    	100%
    	{
    		200px;
    	}	
    }
      @-moz-keyframes move
    {
    	0%{
    		100px;
    	}
    	100%
    	{
    		200px;
    	}	
    }
        @keyframes move
    {
    	0%{
    		100px;
    	}
    	100%
    	{
    		200px;
    	}	
    }
    .box{100px;height:100px;background:red; -webkit-animation:move 2s 1s ease-in-out 4 alternate forwards; -moz-animation:move 2s 1s ease-in-out 4 alternate forwards;animation:move 2s 1s ease-in-out 4 alternate forwards;}
    .box:hover{-webkit-animation-play-state:paused;-moz-animation-play-state:paused;animation-play-state:paused }
    </style>
    </head>
    <body>
    <div class="box"></div>
    </body>
    </html>
    
    
    
  • 相关阅读:
    c#以文件流的形式输出xml(可以解决内存溢出)-XmlTextWriter
    c# 大数据量比较时-方案
    c# 大数据量比较时-方案
    sql中插入多条记录-微软批处理
    sql中插入多条记录-微软批处理
    c#上传图片
    c#上传图片
    sql 数据库优化
    mysql处理旧数据-使用模板以及临时表,不建议直接使用本表!!
    margin-bottom无效问题以及div里内容动态居中样式!
  • 原文地址:https://www.cnblogs.com/leee/p/5483105.html
Copyright © 2011-2022 走看看