Siddharth
Siddharth

Reputation: 5219

Twitter Bootstrap 3 navbar doesn't collapse on mobile devices

My navbar code looks is -

<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>

But the nabber doesn't collapse on mobile devices or when I shrink the browser size. It just disappears. I saw somewhere that this might be because I might not be setting the meta tag for viewport correctly but I have -

<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">

How can I debug this issue?

Upvotes: 1

Views: 3732

Answers (1)

Marcin Łojewski
Marcin Łojewski

Reputation: 127

I think You are missing the following declaration in Your navbar header that displays the toggle button:

<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>

Upvotes: 3

Related Questions