Twitter Bootstrap 3导航栏不会在移动设备上崩溃

时间:2015-02-25 10:04:21

标签: twitter-bootstrap

我的导航条代码看起来是 -

<body>

        <!--Navbar -->
        <nav class="navbar navbar-inverse navbar-fixed-top">
            <div class="container-fluid">

                <div class="navbar-header">
                    <a class="navbar-brand" href="#" style="color: #FFFFFF;">TALENTMATCH</a>
                </div>

                <div class="collapse navbar-collapse" id="navbarHeaderCollapse" style="font-size: 13px;">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="/jobs">JOBS</a></li>
                        {% if current_user.is_authenticated() %}
                        <li><a href="/profile">PROFILE</a></li>
                        {% else %}
                        <li><a href="/login">SIGN IN</a></li>
                        {% endif %}
                    </ul>
                </div>
            </div>
        </nav>

但是nabber在移动设备上或者缩小浏览器大小时不会崩溃。它只是消失了。我在某个地方看到这可能是因为我可能没有正确设置视口的元标记,但我有 -

<html lang="en">

    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">

如何调试此问题?

1 个答案:

答案 0 :(得分:3)

我认为您在显示切换按钮的导航栏标题中缺少以下声明:

<div class="navbar-header">
   <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#navbarHeaderCollapse">
     <span class="sr-only">Toggle navigation</span>
     <span class="icon-bar"></span>
     <span class="icon-bar"></span>
     <span class="icon-bar"></span>
   </button>
   ...
</div>