Bootstrap导航栏调整

时间:2018-11-18 08:40:36

标签: html twitter-bootstrap

我尝试对齐导航栏,该导航栏位于我的网页顶部,但不知何故,其中之一直接出现在“ Kontakt”下方。

我希望所有物品都必须在同一行。第二个问题是,当我单击徽标时,无法再次将其重定向到我的页面顶部。

Screenshoot

代码:

<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
        <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>
            <img src="img/ico2.png" class="img-responsive" alt="logo">
        </div>
        <div class="collapse navbar-collapse text-center" id="bs-example-navbar-collapse-1">
            <div class="col-md-8 col-xs-12 nav-wrap">
                <ul class="nav navbar-nav">
                    <li><a href="#owl-hero" class="page-scroll"><i class="fa fa-windows"></i> Witamy</a></li>
                    <li><a href="#services" class="page-scroll"><i class="fa fa-dropbox"></i> Usługi</a></li>
                    <li><a href="#portfolio" class="page-scroll"><i class="fa fa-user"></i> Realizacje</a></li>
                    <li><a href="#cooperation" class="page-scroll"><i class="fa fa-user"></i> Etapy </a></li>
                    <li><a href="#team" class="page-scroll"><i class="fa fa-stack-exchange"></i> O nas</a></li>
                    <li><a href="#contact" class="page-scroll"><i class="fa fa-whatsapp"></i> Kontakt</a></li>
                </ul>
            </div>
            <!-- <div class="social-media hidden-sm hidden-xs">
            <ul class="nav navbar-nav">
                <li>
                    <a href="https://www.mywebpage.com/"><i class="fa fa-facebook"></i></a>
                </li>
            </ul>
        </div> -->
        </div>
    </div>
</nav>

1 个答案:

答案 0 :(得分:0)

div#bs-example-navbar-collapse-1不需要包装navbar就可以工作。 并在图像周围包裹一个链接标记,以将其重定向到您的首页。

更新
问题1)Bootstrap可以在导航栏中显示的项目数有限制。请检查docs并阅读限制。
问题2)我已修复代码。请确保已加载jQuery和bootstrap JS文件。
问题3)我无法重现该问题。似乎与徽标大小有关。您可以发布jsFiddle吗?

已更新,这是固定代码:

<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <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="//www.your-any-webste.com/"><img src="img/ico2.png" class="img-responsive" alt="logo"></a>
    </div>

    <ul class="nav navbar-nav collapse navbar-collapse text-center" id="bs-example-navbar-collapse-1">
      <li><a href="#owl-hero" class="page-scroll"><i class="fa fa-windows"></i> Witamy</a></li>
      <li><a href="#services" class="page-scroll"><i class="fa fa-dropbox"></i> Usługi</a></li>
      <li><a href="#portfolio" class="page-scroll"><i class="fa fa-user"></i> Realizacje</a></li>
      <li><a href="#cooperation" class="page-scroll"><i class="fa fa-user"></i> Etapy </a></li>
      <li><a href="#team" class="page-scroll"><i class="fa fa-stack-exchange"></i> O nas</a></li>
      <li><a href="#contact" class="page-scroll"><i class="fa fa-whatsapp"></i> Kontakt</a></li>
    </ul>
  </div>
</nav>