megamenu 下拉 bootstrap 移动崩溃
megamenu dropdown bootstrap mobile collapse
因此,由于 Bootstrap,我有一个可以正常工作并按比例缩小的下拉菜单。
然而,客户希望折叠起来像手风琴一样。
我正在努力达到 this 之类的目的。 Avada 的主导航 menu-scaled 向下移动:请注意 'Home Samples' header 是如何丢失的,并成为列表项作为其下拉列表的切换。我如何才能找出创建此内容所用的内容?将不胜感激向正确的方向推进。
这是我得到的fiddle。
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown" id="header1"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Apparel</a>
<ul class="dropdown-menu mega-dropdown-menu row mega-dropdown-menu-1">
<div class="dropimg"><img class="img-responsive" src="images/dropdown.jpg"> </div>
<li class="col-sm-2">
<ul>
<li class="dropdown-header">APPAREL</li>
<li class="dropdown-header_a"><a href="#" class="dropdown-toggle" data-toggle="dropdown">ALL PRODUCTS</a>
<ul class="dropdown-menu">
<li><a href="">Bottoms</a></li>
<li><a href="">Formal Wear</a></li>
<li><a href="">Golfers</a></li>
<li><a href="">Jackets</a></li>
<li><a href="">Knitwear</a></li>
<li><a href="">Shirts</a></li>
<li><a href="">Sweaters</a></li>
<li><a href="">Tracksuits</a></li>
<li><a href="">T-Shirts</a></li>
</ul>
</li>
</ul>
</li>
<li class="col-sm-2">
<ul>
<li class="dropdown-header"> </li>
<li class="dropdown-header_a">BRANDS</li>
<li><a href="">Altitude</a></li>
<li><a href="">Birdi</a></li>
<li><a href="">Chefworks</a></li>
<li><a href="">Drimac</a></li>
<li><a href="">Flexfit</a></li>
<li><a href="">Lexor</a></li>
<li><a href="">SA Rugby</a></li>
<li><a href="">Underarmour</a></li>
</ul>
</li>
<li class="col-sm-2">
<ul>
<li class="dropdown-header"> </li>
<li class="dropdown-header_a">CATEGORY</li>
<li><a href="">Activewear</a></li>
<li><a href="">Hospitality</a></li>
<li><a href="">Locally Produced</a></li>
<li><a href="">Outdoor</a></li>
<li><a href="">Supporters</a></li>
<li><a href="">Team Wear</a></li>
<li><a href="">Workplace</a></li>
</ul>
</li>
<li class="col-sm-2">
<ul>
<li class="dropdown-header"> </li>
<li class="dropdown-header_a">CLEARANCE</li>
</ul>
</li>
<li class="col-sm-1">
<ul>
<li class="dropdown-header"> </li>
<li class="dropdown-header_a">SPECIALS</li>
</ul>
</li>
</ul>
</li>
</ul>
在fiddle。下拉列表中的第一个
,我尝试将其设为正常的下拉列表。有没有办法让它在不使用 java 的情况下工作?
[已编辑]
通过一些研究和耐心,我设法向 bootstrap 下拉列表添加了一个稍微类似的类似手风琴的过渡效果。我还设法修复了下拉菜单向上滑动过快时发生的视觉错误。
在 bootstrap 3 中,他们公开了很多 javascript 事件供我们修改。我们将使用的事件是:'show.bs.dropdown' 和 'hide.bs.dropdown'。 Learn more about their javascript events. Or check out the Dropdown events.
在每个事件中,我们将添加几行 jquery 行来为下拉菜单提供我们想要的效果。 jquery 事件是:slideDown and slideUp.
剩下的就是覆盖 bootstrap 的默认导航栏颜色并为其添加您自己的样式。
结果如下(点击最右边的phone图标):Bootply example
Javascript/Jquery:
$(function(){
//Add OnResize event
window.onresize = myResize;
myResize();
});
//This finction will fire each time the browser is resized
function myResize(){
//Get browser/device height and width
var bWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var bHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
//If viewport is lower than ipad, hence mobile
if(bWidth < 768){
// ADD SLIDEDOWN ANIMATION TO DROPDOWN //
$('.dropdown').on('show.bs.dropdown', function(e){
$(this).find('.dropdown-menu').first().stop(true, true).slideDown();
});
// ADD SLIDEUP ANIMATION TO DROPDOWN //
$('.dropdown').on('hide.bs.dropdown', function(e){
e.preventDefault();
$(this).find('.dropdown-menu').first().stop(true, true).slideUp(400, function(){
//On Complete, we reset all active dropdown classes and attributes
//This fixes the visual bug associated with the open class being removed too fast
$('.dropdown').removeClass('open');
$('.dropdown').find('.dropdown-toggle').attr('aria-expanded','false');
});
});
}
}
HTML/Bootstrap 导航栏:
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">APPAREL <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Bottoms</a></li>
<li><a href="#">Formal Wear</a></li>
<li><a href="#">Golfers</a></li>
<li><a href="#">Jackets</a></li>
<li><a href="#">Knitwear</a></li>
<li><a href="#">Shirts</a></li>
<li><a href="#">Sweaters</a></li>
<li><a href="#">Tracksuits</a></li>
<li><a href="#">T-Shirts</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">BRANDS <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Altitude</a></li>
<li><a href="#">Birdi</a></li>
<li><a href="#">Chefworks</a></li>
<li><a href="#">Drimac</a></li>
<li><a href="#">Flexfit</a></li>
<li><a href="#">Lexor</a></li>
<li><a href="#">SA Rugby</a></li>
<li><a href="#">Underarmour</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">CATEGORY <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Activewear</a></li>
<li><a href="#">Hospitality</a></li>
<li><a href="#">Locally Produced</a></li>
<li><a href="#">Outdoor</a></li>
<li><a href="#">Supporters</a></li>
<li><a href="#">Team Wear</a></li>
<li><a href="#">Workplace</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li><a href="#">CLEARANCE</a></li>
<li><a href="#">SPECIALS</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
因此,由于 Bootstrap,我有一个可以正常工作并按比例缩小的下拉菜单。
然而,客户希望折叠起来像手风琴一样。
我正在努力达到 this 之类的目的。 Avada 的主导航 menu-scaled 向下移动:请注意 'Home Samples' header 是如何丢失的,并成为列表项作为其下拉列表的切换。我如何才能找出创建此内容所用的内容?将不胜感激向正确的方向推进。
这是我得到的fiddle。
<ul class="nav navbar-nav">
<li class="dropdown mega-dropdown" id="header1"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Apparel</a>
<ul class="dropdown-menu mega-dropdown-menu row mega-dropdown-menu-1">
<div class="dropimg"><img class="img-responsive" src="images/dropdown.jpg"> </div>
<li class="col-sm-2">
<ul>
<li class="dropdown-header">APPAREL</li>
<li class="dropdown-header_a"><a href="#" class="dropdown-toggle" data-toggle="dropdown">ALL PRODUCTS</a>
<ul class="dropdown-menu">
<li><a href="">Bottoms</a></li>
<li><a href="">Formal Wear</a></li>
<li><a href="">Golfers</a></li>
<li><a href="">Jackets</a></li>
<li><a href="">Knitwear</a></li>
<li><a href="">Shirts</a></li>
<li><a href="">Sweaters</a></li>
<li><a href="">Tracksuits</a></li>
<li><a href="">T-Shirts</a></li>
</ul>
</li>
</ul>
</li>
<li class="col-sm-2">
<ul>
<li class="dropdown-header"> </li>
<li class="dropdown-header_a">BRANDS</li>
<li><a href="">Altitude</a></li>
<li><a href="">Birdi</a></li>
<li><a href="">Chefworks</a></li>
<li><a href="">Drimac</a></li>
<li><a href="">Flexfit</a></li>
<li><a href="">Lexor</a></li>
<li><a href="">SA Rugby</a></li>
<li><a href="">Underarmour</a></li>
</ul>
</li>
<li class="col-sm-2">
<ul>
<li class="dropdown-header"> </li>
<li class="dropdown-header_a">CATEGORY</li>
<li><a href="">Activewear</a></li>
<li><a href="">Hospitality</a></li>
<li><a href="">Locally Produced</a></li>
<li><a href="">Outdoor</a></li>
<li><a href="">Supporters</a></li>
<li><a href="">Team Wear</a></li>
<li><a href="">Workplace</a></li>
</ul>
</li>
<li class="col-sm-2">
<ul>
<li class="dropdown-header"> </li>
<li class="dropdown-header_a">CLEARANCE</li>
</ul>
</li>
<li class="col-sm-1">
<ul>
<li class="dropdown-header"> </li>
<li class="dropdown-header_a">SPECIALS</li>
</ul>
</li>
</ul>
</li>
</ul>
在fiddle。下拉列表中的第一个
[已编辑]
通过一些研究和耐心,我设法向 bootstrap 下拉列表添加了一个稍微类似的类似手风琴的过渡效果。我还设法修复了下拉菜单向上滑动过快时发生的视觉错误。
在 bootstrap 3 中,他们公开了很多 javascript 事件供我们修改。我们将使用的事件是:'show.bs.dropdown' 和 'hide.bs.dropdown'。 Learn more about their javascript events. Or check out the Dropdown events.
在每个事件中,我们将添加几行 jquery 行来为下拉菜单提供我们想要的效果。 jquery 事件是:slideDown and slideUp.
剩下的就是覆盖 bootstrap 的默认导航栏颜色并为其添加您自己的样式。
结果如下(点击最右边的phone图标):Bootply example
Javascript/Jquery:
$(function(){
//Add OnResize event
window.onresize = myResize;
myResize();
});
//This finction will fire each time the browser is resized
function myResize(){
//Get browser/device height and width
var bWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var bHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
//If viewport is lower than ipad, hence mobile
if(bWidth < 768){
// ADD SLIDEDOWN ANIMATION TO DROPDOWN //
$('.dropdown').on('show.bs.dropdown', function(e){
$(this).find('.dropdown-menu').first().stop(true, true).slideDown();
});
// ADD SLIDEUP ANIMATION TO DROPDOWN //
$('.dropdown').on('hide.bs.dropdown', function(e){
e.preventDefault();
$(this).find('.dropdown-menu').first().stop(true, true).slideUp(400, function(){
//On Complete, we reset all active dropdown classes and attributes
//This fixes the visual bug associated with the open class being removed too fast
$('.dropdown').removeClass('open');
$('.dropdown').find('.dropdown-toggle').attr('aria-expanded','false');
});
});
}
}
HTML/Bootstrap 导航栏:
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">APPAREL <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Bottoms</a></li>
<li><a href="#">Formal Wear</a></li>
<li><a href="#">Golfers</a></li>
<li><a href="#">Jackets</a></li>
<li><a href="#">Knitwear</a></li>
<li><a href="#">Shirts</a></li>
<li><a href="#">Sweaters</a></li>
<li><a href="#">Tracksuits</a></li>
<li><a href="#">T-Shirts</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">BRANDS <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Altitude</a></li>
<li><a href="#">Birdi</a></li>
<li><a href="#">Chefworks</a></li>
<li><a href="#">Drimac</a></li>
<li><a href="#">Flexfit</a></li>
<li><a href="#">Lexor</a></li>
<li><a href="#">SA Rugby</a></li>
<li><a href="#">Underarmour</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">CATEGORY <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Activewear</a></li>
<li><a href="#">Hospitality</a></li>
<li><a href="#">Locally Produced</a></li>
<li><a href="#">Outdoor</a></li>
<li><a href="#">Supporters</a></li>
<li><a href="#">Team Wear</a></li>
<li><a href="#">Workplace</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav">
<li><a href="#">CLEARANCE</a></li>
<li><a href="#">SPECIALS</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>