示例站点使用CSS 过渡而不是 JavaScript 来获得所需的效果。看看这个 jsFiddle。它应该指向正确的方向。
HTML:
<div id="menu">
<img src="http://m.liveperson.com/themes/images/menu-icon-hd-36-off.png" />
<nav>
<a href="home.html">Home</a>
<a href="work.html">Work</a>
<a href="contact.html">Contact</a>
<a href="about.html">About</a>
</nav>
</div>
CSS:
#menu img {
cursor: pointer;
display: block;
float: left;
z-index: 2;
transition: transform .25s linear;
-moz-transition: -moz-transform .25s linear;
-webkit-transition: -webkit-transform .25s linear;
-o-transition: -o-transform .25s linear;
}
#menu nav {
display: inline-block;
position: relative;
height: 36px;
z-index: 1;
transition: all .25s linear;
-moz-transition: all .25s linear;
-webkit-transition: all .25s linear;
-o-transition: all .25s linear;
}
#menu.active nav {
left: -20em;
opacity: 0;
}
#menu.active img {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
transform: rotate(90deg);
}
JavaScript:
$("#menu img").click(function() {
$("#menu").toggleClass("active");
});