先来看看第一种实现方式
效果图如下:
不再采用ul li的布局方式
-webkit-transform-style:preserve-3d只对子元素有作用,所以每个div都加。
实例源码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</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>第一项</span>
<div>
<span>第二项</span>
<div>
<span>第三项</span>
<div>
<span>第四项</span>
<div>
<span>第五项</span>
<div>
<span>第六项</span>
<div>
<span>第七项</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>
第二种实现方式
效果图如下:
这个原先是隐藏的,点击后才展开。
通过关键帧控制每个div的展开状态,当要展开的时候给每个div添加className,但是这个className不是一下子全部添加上去的,而是有延时的,所以用到了定时器。
实例源码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</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>标题</h2>
<div>
<span>第一项</span>
<div>
<span>第二项</span>
<div>
<span>第三项</span>
<div>
<span>第四项</span>
<div>
<span>第五项</span>
<div>
<span>第六项</span>
<div>
<span>第七项</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>
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
白云城资源网 Copyright www.dyhadc.com
暂无“利用Js+Css实现折纸动态导航效果实例源码”评论...
更新日志
2025年10月27日
2025年10月27日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]



