我正在尝试使用.slideToggle()
函数制作一个 jQuery 切换菜单(参见jsFiddle)。但是,我想让灰色按钮跟随滑动菜单,即将灰色按钮移动到滑动菜单的顶部。我可以做出哪些改变?
HTML
<div id="categories">
<ul>
<li>Category 1</li>
<li>Category 2</li>
<li>Category 3</li>
<li>Category 4</li>
<li>Category 5</li>
<li>Category 6</li>
</ul>
</div>
<div id="menu">Navigation pane</div>
JS
$(document).ready(function() {
$('#menu').click(function() {
$('#categories').slideToggle('fast');
});
});
CSS
body {
font-family: Arial;
font-size: 12px;
}
#menu_service_nav {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 24px;
line-height: 24px;
background-color: #EEE;
cursor: pointer;
}
#categories {
position: absolute;
bottom: 24px;
height: auto;
width: 100px;
display: none;
border: 1px solid #CCC;
left: 0;
}
#categories ul {
list-style: none;
}
#categories ul li {
margin-left: -30px;
height: 24px;
line-height: 24px;
}