我是新来的,如果这个问题以前就被问过,请原谅,但我找不到这样的问题。一开始,对不起我的语法;)。
问题是,我想得到切换菜单,从右边滑进来后,点击“汉堡包”图标,但只有当屏幕宽度小于576像素。在大屏幕上,我有一个固定的顶部导航条,没有任何效果,这很好。我正在使用Bootstrap 4来构建我的站点。有可能吗?
<nav class="navbar navbar-expand-lg navbar-light fixed-top">
<div class="container-fluid">
<a class="navbar-brand pl-md-4" href="index.html">Logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Link 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 4</a>
</li>
</ul>
<ul class="navbar-nav pr-md-4">
<li class="nav-item px-md-3">
<a class="nav-link" href="#">link 5</a>
</li>
<li class="nav-item px-md-3">
<a class="nav-link" href="#">link 6</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">link 7</a>
</li>
</ul>
</div>
</div>
</nav>
最佳答案
最好的方法是创建两个不同的导航,一个用于大屏幕,另一个用于小屏幕
<!-- Hide the for large Screen -->
<nav id="jsIdentifer1" class="hidden-md hidden-lg">
your navigation code
</nav>
<!-- Hide the for small Screen -->
<nav id="jsIdentifer2" class="hidden-sm hidden-xs">
your navigation code
</nav>