亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

利用Js+Css實(shí)現(xiàn)折紙動態(tài)導(dǎo)航效果實(shí)例源碼

 更新時間:2017年01月25日 09:55:33   投稿:daisy  
這篇文章主要給大家介紹了利用Js+Css實(shí)現(xiàn)折紙動態(tài)導(dǎo)航的效果,實(shí)現(xiàn)后的效果非常不錯,文中給出了簡單的介紹和完整的實(shí)例代碼,對大家具有一定的參考價值,有需要的朋友們下面來一起看看吧。

先來看看第一種實(shí)現(xiàn)方式

效果圖如下:

不再采用ul li的布局方式

-webkit-transform-style:preserve-3d只對子元素有作用,所以每個div都加。

實(shí)例源碼

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無標(biāo)題文檔</title>
<style>
.wrap{margin:30px auto;width:302px;-webkit-perspective:800px; -webkit-transform-style:preserve-3d; position:relative;}
.wrap div{ position:absolute; top:52px;left:0;-webkit-transform-style:preserve-3d; -webkit-transform-origin:top;}
.wrap span{ display:block;width:300px;border:1px solid #000;height:50px; font:16px/50px "宋體"; background:#ccc;}
</style>
</head>
<body>
<input type="button" value="展開" />
<input type="button" value="收縮" />
<div class="wrap" id="list">
 <span>第一項(xiàng)</span>
 <div>
  <span>第二項(xiàng)</span>
  <div>
   <span>第三項(xiàng)</span>
   <div>
    <span>第四項(xiàng)</span>
    <div>
    <span>第五項(xiàng)</span>
     <div>
      <span>第六項(xiàng)</span>
      <div>
       <span>第七項(xiàng)</span>
      </div>
     </div>
    </div>
   </div>
  </div>
 </div>
</div>
<script>
window.onload=function()
{
 var oList=document.getElementById("list");
 var aDiv=oList.getElementsByTagName("div");
 var aBtn=document.getElementsByTagName("input");
 aBtn[1].onclick=function()
 {
 for(var i=0;i<aDiv.length;i++)
 {
 aDiv[i].style.transition="0.5s "+(aDiv.length-i)*100+"ms";
 aDiv[i].style.WebkitTransform="rotateX(60deg)";
 }
 };
 aBtn[0].onclick=function()
 {
 for(var i=0;i<aDiv.length;i++)
 {
 aDiv[i].style.transition="0.5s "+i*100+"ms";
 aDiv[i].style.WebkitTransform="rotateX(0deg)";
 }
 };
};
</script>
</body>
</html>

第二種實(shí)現(xiàn)方式

效果圖如下:

這個原先是隱藏的,點(diǎn)擊后才展開。

通過關(guān)鍵幀控制每個div的展開狀態(tài),當(dāng)要展開的時候給每個div添加className,但是這個className不是一下子全部添加上去的,而是有延時的,所以用到了定時器。

實(shí)例源碼

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無標(biāo)題文檔</title>
<style>
@-webkit-keyframes open{
 0%
 {
 -webkit-transform:rotateX(-120deg);
 } 
 40%
 {
 -webkit-transform:rotateX(30deg);
 }
 60%
 {
 -webkit-transform:rotateX(-20deg);
 }
 80%
 {
 -webkit-transform:rotateX(10deg);
 }
 100%
 {
 -webkit-transform:rotateX(0deg);
 }
}
.wrap{margin:30px auto;width:300px;-webkit-perspective:800px;position:relative;}
.wrap h2{ height:50px;background:#F03; text-align:center; font:16px/50px "微軟雅黑"; color:#fff; position:relative;z-index:2;}
.wrap div{ position:absolute; top:32px;left:0;-webkit-transform-style:preserve-3d; -webkit-transform-origin:top; -webkit-transform:rotateX(-120deg); transition:.5s;}
.wrap>div{ top:50px;}
.wrap .open{-webkit-animation:open 2s;-webkit-transform:rotateX(0deg);}
.wrap span{ display:block;width:300px;height:30px; font:14px/30px "宋體"; background:#6F3; text-indent:15px; color:#fff; transition:.5s; box-shadow:inset 0 0 30px 20px rgba(0,0,0,1);}
.wrap .open>span{box-shadow:inset 0 0 30px 10px rgba(0,0,0,0);}
.wrap span:hover{ background:#FF0;text-indent:30px;}
</style>
</head>
<body>
<input type="button" value="展開" />
<input type="button" value="收縮" />
<div class="wrap" id="list">
 <h2>標(biāo)題</h2>
 <div>
  <span>第一項(xiàng)</span>
  <div>
   <span>第二項(xiàng)</span>
   <div>
    <span>第三項(xiàng)</span>
    <div>
     <span>第四項(xiàng)</span>
     <div>
      <span>第五項(xiàng)</span>
      <div>
       <span>第六項(xiàng)</span>
       <div>
        <span>第七項(xiàng)</span>
       </div>
      </div>
     </div>
    </div>
   </div>
  </div>
 </div> 
</div>
<script>
window.onload=function()
{
 var oList=document.getElementById("list");
 var aDiv=oList.getElementsByTagName("div");
 var aBtn=document.getElementsByTagName("input");
 var oTimer=null;
 aBtn[1].onclick=function()
 {
 var i=aDiv.length-1;
 clearInterval(oTimer);
 oTimer=setInterval(function(){
 aDiv[i].className="";
 i--;
 if(i<0)
 {
 clearInterval(oTimer);
 }
 },50); 
 };
 aBtn[0].onclick=function()
 {
 var i=0;
 clearInterval(oTimer);
 oTimer=setInterval(function(){
 aDiv[i].className="open";
 i++;
 if(i==aDiv.length)
 {
 clearInterval(oTimer);
 }
 },200);
 };
};
</script>
</body>
</html>

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。

相關(guān)文章

最新評論