从下往上切换导航栏
html javascript toggle navbar from bottom up
本文关键字:导航 更新时间:2023-09-26
我已经练习了一种从左到右切换侧边栏菜单的方法。下面是代码:
https://jsfiddle.net/2z84zyjz/3/
但是我找不到让它从下往上切换的方法。你们知道吗?
Toggle
$("#menu-toggle").click(function(e) {
e.preventDefault();
$(".navbar").slideUp();
});
$('#menu-toggle').dblclick(function(e) {
$(".navbar").slideDown();
});
#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
background-color: aqua;
height: 400px;
}
#wrapper.toggled {
padding-top: 250px;
}
#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 250px;
width: 0;
height: 100%;
margin-left: -250px;
overflow-y: auto;
background: #050545;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
box-shadow: inset -10px 0px 10px -7px grey;
}
#wrapper.toggled #sidebar-wrapper {
height: 250px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div id="wrapper">
<div id="header" class="container-fluid" style="padding-top:100px;"> <a href="#menu-toggle" id="menu-toggle">Toggle</a>
<div class="navbar"> <a class="navbar-brand">Heading <span id="counterId"></span></a>
</div>
</div>
</div>
<div id="sidebar-wrapper"></div>
使用slideUp()
和slideDown()
方法来显示/隐藏导航条
jsfiddle
使用以下解决方案: