Search code examples
csstwitter-bootstrapmobilenavbarvertical-alignment

NavBar Justified stacking vertically on Mobile


My Top NavBar using bootstrap it's fine on desktop but when I browser my website using my Mobile the navbar links appear stacked vertically, instead of horizontal, why is this happening? any clue?

I am using bootstrap, here is my code:

@import 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css';
 body {
  background: black url(Images/image.png) no-repeat center center;
  height: 100vh;
}
.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 50px;
}
.navBarLinks {
  color: white;
}
.navBarLinks:hover {
  color: black;
}
.body-content {} .dl-horizontal dt {
  white-space: normal;
}
input,
select,
textarea {
  max-width: 280px;
}
<ul class="nav nav-justified navbar-inverse">
  <li><a class="navBarLinks">Stuff1</a>
  </li>
  <li><a class="navBarLinks">Stuff2</a>
  </li>
  <li><a class="navBarLinks">Stuff3</a>
  </li>
  <li><a class="navBarLinks">Stuff4</a>
  </li>
  <li><a class="navBarLinks">Stuff5</a>
  </li>
</ul>
//more stuff not relevant

Thank you in advance!


Solution

  • <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.7/js/bootstrap.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <nav class="navbar navbar-default">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <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>
    
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav">
            <li><a class="navBarLinks">Stuff1</a></li>
            <li><a class="navBarLinks">Stuff2</a></li>
            <li><a class="navBarLinks">Stuff3</a></li>
            <li><a class="navBarLinks">Stuff4</a></li>
            <li><a class="navBarLinks">Stuff5</a></li>
          </ul>
        </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
    </nav>

    This is a basic example of what I was talking about...using bootstrap example.

    https://getbootstrap.com/examples/navbar/

    When you "Run code snippet" open it up using the full page button and then shrink browser to get a better idea.