jQuery:
$(".sn a").on('click',function(){
var panID = $("#" + $(this).data('panel') );
$("div[id*='sn-pan-']").hide({slide:'toggle'}, 1000);
$(panID).css("left","100px").animate({width:'toggle'}, 500)
});
侧导航 HTML:
<ul class="sidenav">
<li class="sn"><a href="#" data-panel="sn-pan-1">Lorem</a></li>
<li class="sn"><a href="#" data-panel="sn-pan-2">Ipsum</a></li>
<li class="sn"><a href="#" data-panel="sn-pan-3">Dolar</a></li>
<li class="sn"><a href="#" data-panel="sn-pan-4">Sit</a></li>
<li class="sn"><a href="#" data-panel="sn-pan-5">Amet</a></li>
<li class="sn"><a href="#" data-panel="sn-pan-6">Et</a></li>
<li class="sn"><a href="#" data-panel="sn-pan-7">Donut</a></li>
</ul>
侧导航面板 HTML:
<!-- hidden panel that slides out? -->
<div id="sn-pan-1">
<ul>
<li>Stuff 1</li>
<li>Here</li>
</ul>
</div>
<div id="sn-pan-2">
<ul>
<li>Stuff 1</li>
<li>Here</li>
</ul>
</div>
...
...
<div id="sn-pan-7">
<ul>
<li>Stuff 7</li>
<li>Here</li>
</ul>
</div>
CSS:
.sn a {
width: 100%;
display: block;
overflow: hidden;
padding: 10px 0;
border-bottom: 1px solid #
}
div[id*="sn-pan-"]{
float: left;
background: red;
width: 100px;
height: 100%;
position: absolute;
left: 0px;
top: 0;
display: none;
}