NavBar在移动设备上垂直堆叠

时间:2016-10-01 20:11:36

标签: css twitter-bootstrap mobile navbar vertical-alignment

My Top NavBar使用bootstrap它在桌面上很好但是当我使用我的Mobile浏览我的网站时,导航栏链接显示为垂直堆叠而不是水平,为什么会发生这种情况?任何线索?

我正在使用bootstrap,这是我的代码:

@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

提前谢谢!

1 个答案:

答案 0 :(得分:1)

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

这是我所说的基本示例......使用bootstrap示例。

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

当您“运行代码段”时,使用整页按钮打开它,然后缩小浏览器以获得更好的想法。