Javascript 为什么引导下拉菜单不';如果导航栏具有固定高度,则无法工作?
我有一个包含20多个项目的菜单,我想获得一个固定的导航高度,因此超过容器宽度的菜单不会中断,而是隐藏Javascript 为什么引导下拉菜单不';如果导航栏具有固定高度,则无法工作?,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我有一个包含20多个项目的菜单,我想获得一个固定的导航高度,因此超过容器宽度的菜单不会中断,而是隐藏 ul.fixedHeight { height: 50px; overflow: hidden; } 然后,我用jQuery检查是否有隐藏菜单来显示按钮。navbar切换向下滑动并显示隐藏菜单: JS: 最后,如果窗口大小大于768或调整大小时,我将运行该函数。 问题是,当窗口大小大于768,我单击按钮显示隐藏项时,向下滑动不起作用,但当窗口大小小于768时,向下滑动起作用
ul.fixedHeight {
height: 50px;
overflow: hidden;
}
然后,我用jQuery检查是否有隐藏菜单来显示按钮。navbar切换
向下滑动并显示隐藏菜单:
JS:
最后,如果窗口大小大于768或调整大小时,我将运行该函数。
问题是,当窗口大小大于768,我单击按钮显示隐藏项时,向下滑动不起作用,但当窗口大小小于768时,向下滑动起作用
感谢您的帮助!谢谢大家! 如前所述,当按动按钮时,高度限制了它的生长。但是,您可以使用javascript解决此问题:
//initially the button is not clicked
clicked=false;
$('button.navbar-toggle').click(function(){
if(clicked==false)
{
//if the button isn't clicked and you click it,
//let the height grow and make the overflow property as visible
$('.nav.navbar-nav.fixedHeight').css('overflow','visible');
$('.nav.navbar-nav.fixedHeight').css('height','auto');
clicked=true;
}
else
{
//vice versa when you need to close it
$('.nav.navbar-nav.fixedHeight').css('overflow','hidden');
$('.nav.navbar-nav.fixedHeight').css('height','50px');
clicked=false;
}
});
@media (min-width: 768px) {
button.navbar-toggle {
position: absolute;
bottom: 0;
margin-left: -50px;
background: #000;
}
button.navbar-toggle.hidden {
display:none;
}
button.navbar-toggle.visible {
display:block;
}
}
//initially the button is not clicked
clicked=false;
$('button.navbar-toggle').click(function(){
if(clicked==false)
{
//if the button isn't clicked and you click it,
//let the height grow and make the overflow property as visible
$('.nav.navbar-nav.fixedHeight').css('overflow','visible');
$('.nav.navbar-nav.fixedHeight').css('height','auto');
clicked=true;
}
else
{
//vice versa when you need to close it
$('.nav.navbar-nav.fixedHeight').css('overflow','hidden');
$('.nav.navbar-nav.fixedHeight').css('height','50px');
clicked=false;
}
});