Bootstrap 3.0导航响应切换按钮不起作用 [英] Bootstrap 3.0 nav responsive toggle button not working

查看:71
本文介绍了Bootstrap 3.0导航响应切换按钮不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经检查出与此问题类似的答案,并在此处设置了与此响应类似的代码,但仍然无法使它正常工作

I have checked out similar answers to this question and have set up my code similar to this response here, but still cannot get it to work:

引导3导航栏折叠按钮不起作用

我什至尝试在Bootstrap 3站点上使用默认navbar的确切代码,但是仍然无法正常工作.

I even tried using the exact code for the default navbar on the Bootstrap 3 site, but it still doesn't work.

我已经在头部添加了这两个链接,并且我的路径是正确的:

I've included these two links in the head section and my paths are correct:

http://netdna.bootstrapcdn.com/bootstrap /3.1.1/css/bootstrap.min.css http://netdna.bootstrapcdn.com/bootstrap/3.1. 1/js/bootstrap.min.js "

我的相关代码:

<nav class="navbar navbar-default navbar-fixed-top navbar-inverse role"="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
                <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>
        <div class="collapse navbar-collapse" id="nav-collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#about">About</a></li>
                <li><a href="#reviews">Reviews</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </div>
    </div>
</nav>

推荐答案

您犯了一些小错误,这就是按钮不起作用的原因:

You've made a couple of small errors which is why the button doesn't work:

1)您在<nav>元素上有一个错字,在navbar-inverse role"="navigation"

1) You have a typo on the <nav> element with a misplaced quote at navbar-inverse role"="navigation"

2)按钮的data-target应该是#nav-collapse,因为它是ID,而不是类.

2) Your data-target for the button should be #nav-collapse since it's an id and not a class.

就是这样,这是 工作 版本.

That's it, here's the working version.

这篇关于Bootstrap 3.0导航响应切换按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆