通过创建滑动菜单,我能够做到这一点,但是,我不确定我输入了什么错误,因为菜单不会为我滑动。我试图让菜单在单击“选项卡”时向右滑动,然后当再次单击“选项卡”时,我希望菜单缩回到屏幕的左侧。
简而言之,我的问题是:
1. 为什么菜单不会滑动?
<html> <head> <meta charset="utf-8" />
<script type="text/javascript" src="js/jquery-1.4.min.js"></script> <script type="text/javascript">
$(document).ready(function() {
$("#tab").toggle(function() {
$('#menu').animate({ left: '0' }, 500px);
$("#tab").html('-');
}, function() {
$('#menu').animate({ left: '-600' }, 500px);
$("#tab").html('+');
}); }); </script>
<style type="text/css">
#menu{
position:absolute;
top:0;
left:0;
height:520px;
width:100%;
background-color:#000000;
text-align:center;
margin:0px;
font-family:helvetica;
color:#FFFFFF
opacity:.9; }
a{
padding-right:60px;
text-decoration:none;
margin:40px;
color:#FFFFFF
} h1{
font-size:20px;
padding:40px;
color:#FFFFFF
text-margin:50px;
} h2{
font-size:60px;
padding:70px;
color:#FFFFFF } h3{
font-size:15px;
padding:50px;
color:#FFFFFF }
#tab{
position:absolute;
height:90px;
width:90px;
right:-6%;
top:0px;
background-color:#000000;
font-family:helvetica;
color:#FFFFFF;
font-size:50px;
cursor:pointer; }
</style>
</head>
<body>
<div id="menu"><h1>
<a class="navItem" href="url">about me</a>
<a class="navItem" href="url">book</a>
<a class="navItem" href="url">resume</a>
<a class="navItem" href="url">ask</a>
<a class="navItem" href="url">archive</a></h1>
<h2>title</h2>
<h3>websitetitle</h3>
<div id="tab"> +
</div>
</body>