gpt4 book ai didi

javascript - 导航栏折叠菜单不适用于手机和平板电脑视口(viewport)

转载 作者:可可西里 更新时间:2023-11-01 13:03:41 26 4
gpt4 key购买 nike

我在较小的 viewport 上遇到了 bootstrap3 navbar-menu 问题。当我在检查器中进入响应模式并单击 汉堡包 图标时,我没有看到任何交互,调试工具没有显示任何错误,而且我有所有标准的 bootstrap3 navbar collapse 类代码以支持更小的viewport,我只是忽略了一些东西。

<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="{% url 'index' %}"><img src="static/img/SNYClogo.png" height=50 width=110></a>
</div>
<div class="navbar-collapse collapse">
<ul id="navbar" class="nav navbar-nav navbar-right">
<li><a href="{% url 'index' %}">Home</a></li>
<li><a href="#">Apartments</a></li>
<li><a href="#">About</a></li>
{% if user.is_authenticated %}
<li><a id="logout" href="/accounts/logout">Logout</a></li>
{% else %}
<li class="pull-right" id="showlogin"><a href="#"><button type="button" class="btn btn-sm btn-info round">GET STARTED</button></a></li>
{% endif %}
</ul>
</div><!--/.navbar-collapse -->
</div>
</nav>

有人可以检查这个JSFIDDLE ,并检查我的代码。

最佳答案

.navbar id 给父级 div 而不是 ul

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="#"><img src="..." height=50 width=110></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="{% url 'index' %}">Home</a></li>
<li><a href="#">Apartments</a></li>
<li><a href="#">About</a></li>
{% if user.is_authenticated %}
<li><a id="logout" href="/accounts/logout">Logout</a></li>
{% else %}
<li class="pull-right" id="showlogin"><a href="#"><button type="button" class="btn btn-sm btn-info round">GET STARTED</button></a></li>
{% endif %}
</ul>
</div><!--/.navbar-collapse -->
</div>
</nav>

Fiddle

关于javascript - 导航栏折叠菜单不适用于手机和平板电脑视口(viewport),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35788912/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com