transition-timing-function用来定义过渡动画的效果。
语法项目 | 说明 |
---|---|
初始值 | ease |
适用于 | 所有元素 |
可否继承 | 否 |
媒介 | 视觉 |
版本 | CSS3.0 |
transition-timing-function可以设置动画的过渡效果,默认值ease。
ease:缓解效果,等同于cubic-bezier(0.25,0.1,0.25,1.0)函数,既立方贝塞尔。
linear:线性效果,等同于cubic-bezier(0.0,0.0,1.0,1.0)函数。
ease-in:渐显效果,等同于cubic-bezier(0.42,0,1.0,1.0)函数。
ease-out:渐隐效果,等同于cubic-bezier(0,0,0.58,1.0)函数。
ease-in-out:渐显渐隐效果,等同于cubic-bezier(0.42,0,0.58,1.0)函数。
cubic-bezier:特殊的立方贝塞尔曲线效果。
.demo_box{ -webkit-transition:all 2s 0.5s; -moz-transition:all 2s 0.5s; position:relative; left:10px; width:50px; height:50px; border-radius:50px; margin:10px 0; overflow:hidden; } .ease{ -webkit-transition-timing-function:ease; -moz-transition-timing-function:ease; } .linear{ -webkit-transition-timing-function:linear; -moz-transition-timing-function:linear; } .ease-in{ -webkit-transition-timing-function:ease-in; -moz-transition-timing-function:ease-in; } .ease-out{ -webkit-transition-timing-function:ease-out; -moz-transition-timing-function:ease-out; } .ease-in-out{ -webkit-transition-timing-function:ease-in-out; -moz-transition-timing-function:ease-in-out; } .cubic-bezier{ -webkit-transition-timing-function:cubic-bezier(0.52,0,0.58,1.0); -moz-transition-timing-function:cubic-bezier(0.52,0,0.58,1.0); } .run{ left:500px; }
<div class="demo_box ease">ease</div> <div class="demo_box linear">linear</div> <div class="demo_box ease-in">ease-in</div> <div class="demo_box ease-out">ease-out</div> <div class="demo_box ease-in-out">ease-in-out</div> <div class="demo_box cubic-bezier">cubic-bezier(0.52,0,0.58,1.0)</div> <input type="button" id="run" value="运行" style="margin:10px 10px;" /> <script> $(function(){ $("#run").toggle(function(){ $(".demo_box").addClass("run"); $(this).val("返回"); },function(){ $(".demo_box").removeClass("run"); $(this).val("运行"); }); }); </script>
IE | Firefox | Opera | Safari | Chrome |
---|---|---|---|---|
IE 10+ | Firefox 3.5+ | Opera 11.50+ | Safari 10+ | Chrome 2.0+ |