我正在尝试构建一个菜单,该菜单具有折纸之类的过渡,有点像这样:
现场测试: http ://www.cssplay.co.uk/menus/cssplay-3d-unfolding-menu.html
这是我的代码:
HTML
<nav>
<li class="hov">Hover Me!
<ul class="main">
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item4</li>
</ul>
</li>
</nav>
CSS
nav{
}
ul,li{
margin: 0;
padding: 0;
}
.main{
position:absolute;
z-index:1;
}
.main li{
list-style:none;
background: blue;
width:100px;
padding: 0 5px;
border: 1px solid black;
height: 30px;
line-height: 30px;
/*margin-top: -30px;*/
-webkit-transition: all .5s ease-in-out;
}
.main li:nth-child(odd){
-webkit-transform-origin: top;
-webkit-transform: perspective(350px) rotateX(-90deg);
}
.main li:nth-child(even){
-webkit-transform-origin: bottom;
-webkit-transform: perspective(350px) rotateX(90deg);
}
.main {
-webkit-transition: all .5s ease-in-out;
-webkit-transform-origin: 50% 0%;
-webkit-transform: perspective(350px) rotateX(-90deg);
}
.hov:hover .main {
-webkit-transform-origin: top;
-webkit-transform: perspective(350px) rotateX(0deg);
}
.hov:hover li:nth-child(odd){
-webkit-transform-origin: top;
-webkit-transform: perspective(350px) rotateX(0deg);
margin-top:0;
}
.hov:hover li:nth-child(even){
-webkit-transform-origin: bottom;
-webkit-transform: perspective(350px) rotateX(0deg);
margin-top:0;
}
.main li:first-child{
margin-top:0;
}
.hov{
position:relative;
height: 40px;
width:112px;
background: green;
color: white;
font-size: 13px;
font-family: Helvetica;
font-weight:bold;
text-align: center;
line-height: 40px;
list-style:none;
z-index:2;
}
现场演示
http://codepen.io/razvan-tudosa/pen/BxgJl
问题 :
如何使子菜单像示例中那样粘在一起?