星空网 > 软件开发 > 网页设计

CSS3 transition属性

  1. Transition(过渡),设置过渡时间,(transition-duration)
    <head>  <title>无标题文档</title>  <style>    .box{width:100px;height:100px;background:red; transition:500ms;}    .box:hover{ background:blue;width:200px;height:200px;}  </style></head><body>  <div class="box"></div></body>

     

  2. 只设置某一个样式过渡,即要运动的样式,下面的例子设置了width过渡(all | width | height | ... | none):
    <head>  <title>无标题文档</title>  <style>    .box{width:100px;height:100px;background:red; transition:500ms width;}    .box:hover{ background:blue;width:200px;height:200px;}  </style></head><body>  <div class="box"></div></body>

     

  3. 设置运动形式:transition-timing-function (ease[默认值,逐渐变慢], linea[匀速], ease-in[加速], ease-out[减速], ease-in-out[先加速后减速], cubic-besizer[贝塞尔曲线](http://matthewlein.com/ceaser/))
    <head>  <title>无标题文档</title>  <style>    .box{width:100px;height:100px;background:red; transition:5s width cubic-bezier(0.145,1.295,0.000,1.610);}    .box:hover{width:500px;}  </style></head><body>  <div class="box"></div></body>

     

  4. 同时设置多个样式的过渡时间,用逗号分隔开,如下
    <head>  <title>无标题文档</title>  <style>    .box{width:100px;height:100px;background:red; transition:1s width,2s height,3s background;}    .box:hover{width:500px;height:300px;background:blue;}  </style></head><body>  <div class="box"></div></body>

     

  5. 设置延迟时间,transition-delay,即多长时间后开始某个运动,下面的例子中在1s之后高度开始过渡
     1 <head> 2   <title>无标题文档</title> 3   <style> 4     .box{width:100px;height:100px;background:red; transition:1s width,2s 1s height,3s 3s background;} 5     .box:hover{width:500px;height:300px;background:blue;} 6   </style> 7 </head> 8 <body> 9   <div class="box"></div>10 </body>

     

  6. 过渡结束时触发指定的执行函数,在过渡结束时,执行alert(“end”)
    <head>  <title>无标题文档</title>  <style>    .box{width:100px;height:100px;background:red; transition:1s width;}  </style></head><body>  <div class="box" id="box"></div>  <script>    var oBox=document.getElementById("box");    oBox.onclick=function()    {      this.style.width=this.offsetWidth+100+"px";    };    addEnd(oBox,function(){      alert("end");      });    function addEnd(obj,fn)    {      obj.addEventListener('WebkitTransitionEnd',fn,false);      obj.addEventListener('transitionend',fn,false);    }  </script></body>

     

  7. 过渡完成事件
    • Webkit内核: obj.addEventListener('webkitTransitionEnd', function(){}, false);
    • firefox内核:obj.addEventListener('transitionend', function(){}, false);



原标题:CSS3 transition属性

关键词:CSS

CSS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

童话王国,欧洲市场洞察之丹麦篇:https://www.kjdsnews.com/a/555664.html
亚马逊卖家促销叠加损失25万?关于促销必知必会的3件事:https://www.kjdsnews.com/a/555665.html
兰亭集势2021年上半年营收2.34亿美元,实现营收、利润双增长:https://www.kjdsnews.com/a/555666.html
亚马逊竞争这么激烈,独立站适合现在去做吗?:https://www.kjdsnews.com/a/555667.html
“我在eBay上收到了来自亚马逊的快递!”:https://www.kjdsnews.com/a/556660.html
大量亚马逊卖家被迫涨价?跨境慈善家已下线?:https://www.kjdsnews.com/a/556661.html
优秀的亚马逊运营每天必做的二十件事:https://www.xlkjsw.com/news/92277.html
对赌嗜血!深圳大卖卖身之后……:https://www.kjdsnews.com/a/1842198.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流