skip to Main Content

Using this HTML:

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>app</title>
    <meta name="description" content="todoApp">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
  </head>
  <body>
    <div class="container-fluid">
      <nav class="navbar navbar-toggleable-sm navbar-inverse bg-inverse fixed-top">
        <a class="navbar-brand" href="#">App</a>
        <ul class="nav navbar-nav">
          <li class="nav-item">
            <a href="#" class="nav-link">
              home
            </a>
          </li>
          <li class="nav-item">
            <a href="#" class="nav-link">
              about
            </a>
          </li>
          <li class="nav-item">
            <a href="#" class="nav-link">
              admin
            </a>
          </li>
        </ul>
      </nav>
    </div>
  </body>
</html>

The navigation menu looks fine when the browser window is wider that 760px:

enter image description here

However, when the window is less than 760px wide, the menu jumps down:

enter image description here

What is the correct syntax for keeping the menu as is, regardless of the window width. Also, I do not want to put the menu links behind a hamburger button when the window is shrunk.

Thanks!

2

Answers


  1. I’d try using Firebug to inspect the line-item, there is a breakpoint defined somewhere causing the change. The css style is likely wrapped in a @media rule similar to this:

    @media screen and (max-width: 760px) {
       ul.navbar-nav li.nav-item{display: block;}
    }
    

    Feel free to post the CSS related to .nav-item if this doesn’t help.

    Login or Signup to reply.
  2. Bootstrap4 is designed to be mobile first with flex.

    At start flex-direction: column; is on but when you go over 992px it become flex-direction: row;

    That what you’re after.

    The scss file are here https://github.com/twbs/bootstrap/blob/v4-dev/scss/_navbar.scss line 127 to 181.

    You can try to comment line 147 & 178 and check if that work.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search