欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

利用CSS3的transition屬性實(shí)現(xiàn)滑動(dòng)效果

WEB前端開發(fā)   發(fā)布時(shí)間:2015-08-05 18:44:02   作者:佚名   我要評(píng)論
這篇文章主要介紹了利用CSS3的transition屬性實(shí)現(xiàn)滑動(dòng)效果,是CSS3入門學(xué)習(xí)時(shí)的基本應(yīng)用,需要的朋友可以參考下

首先援引一下w3school上的transition基本知識(shí):

定義和用法
transition 屬性是一個(gè)簡寫屬性,用于設(shè)置四個(gè)過渡屬性:
transition-property
transition-duration
transition-timing-function
transition-delay
注釋:請(qǐng)始終設(shè)置 transition-duration 屬性,否則時(shí)長為 0,就不會(huì)產(chǎn)生過渡效果。

201585184048725.jpg (718×154)
語法

CSS Code復(fù)制內(nèi)容到剪貼板
  1. transition: property duration timing-function delay;  


實(shí)現(xiàn)滑動(dòng)效果
只需要一個(gè)DIV元素便可實(shí)現(xiàn)滑動(dòng)效果,避免了使用JavaScript為元素的動(dòng)畫(IE瀏覽器下僅支持IE9以上)
HTML代碼

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <div style="height: 200px; width: 200px; border: 1px solid #ccc;">  
  2.       <div class="slider" id="slider">這里是內(nèi)容</div>  
  3.   </div>  
  4.   <button onclick="document.getElementById('slider').classList.toggle('closed');">點(diǎn)擊看看</button>  

CSS代碼

CSS Code復(fù)制內(nèi)容到剪貼板
  1. .slider {   
  2.     overflow-y: hidden;   
  3.     max-height500px;   
  4.     /* 最大高度 */  
  5.     background: pink;   
  6.     height200px;   
  7.     width200px;   
  8.     /*  Webkit內(nèi)核瀏覽器:Safari and Chrome*/  
  9.     -webkit-transition-property: all;   
  10.     -webkit-transition-duration: .5s;   
  11.     -webkit-transition-timing-function: cubic-bezier(0, 1, 0.5, 1);   
  12.     /*  Mozilla內(nèi)核瀏覽器:firefox3.5+*/  
  13.     -moz-transition-property: all;   
  14.     -moz-transition-duration: .5s;   
  15.     -moz-transition-timing-function: cubic-bezier(0, 1, 0.5, 1);   
  16.     /*  Opera*/  
  17.     -o-transition-property: all;   
  18.     -o-transition-duration: .5s;   
  19.     -o-transition-timing-function: cubic-bezier(0, 1, 0.5, 1);   
  20.     /*  IE9*/  
  21.     -ms-transition-property: all;   
  22.     -ms-transition-duration: .5s;   
  23.     -ms-transition-timing-function: cubic-bezier(0, 1, 0.5, 1);   
  24. }   
  25. .slider.closed {   
  26.     max-height: 0;   
  27. }  

demo演示地址:http://www.zjgsq.com/example?pid=1166

相關(guān)文章

最新評(píng)論