如何在bootstrap上整理这个导航栏?

时间:2016-09-29 10:08:43

标签: html twitter-bootstrap

我正在学习一些Bootstrap,这个问题让我失望了,因为我想知道如何正确整理这个导航栏,我做了一些col,col-offset ......但没有什么可以帮助我...

我想要得到的是:

WANTED NAVBAR

INDEX.HTML(NAVBAR SNIPPET)

<nav class="navbar navbar-inverse">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">
            <img alt="Brand" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAB+0lEQVR4AcyYg5LkUBhG+1X2PdZGaW3btm3btm3bHttWrPomd1r/2Jn/VJ02TpxcH4CQ/dsuazWgzbIdrm9dZVd4pBz4zx2igTaFHrhvjneVXNHCSqIlFEjiwMyyyOBilRgGSqLNF1jnwNQdIvAt48C3IlBmHCiLQHC2zoHDu6zG1iXn6+y62ScxY9AODO6w0pvAqf23oSE4joOfH6OxfMoRnoGUm+de8wykbFt6wZtA07QwtNOqKh3ZbS3Wzz2F+1c/QJY0UCJ/J3kXWJfv7VhxCRRV1jGw7XI+gcO7rEFFRvdYxydwcPsVsC0bQdKScngt4iUTD4Fy/8p7PoHzRu1DclwmgmiqgUXjD3oTKHbAt869qdJ7l98jNTEblPTkXMwetpvnftA0LLHb4X8kiY9Kx6Q+W7wJtG0HR7fdrtYz+x7iya0vkEtUULIzCjC21wY+W/GYXusRH5kGytWTLxgEEhePPwhKYb7EK3BQuxWwTBuUkd3X8goUn6fMHLyTT+DCsQdAEXNzSMeVPAJHdF2DmH8poCREp3uwm7HsGq9J9q69iuunX6EgrwQVObjpBt8z6rdPfvE8kiiyhsvHnomrQx6BxYUyYiNS8f75H1w4/ISepDZLoDhNJ9cdNUquhRsv+6EP9oNH7Iff2A9g8h8CLt1gH0Qf9NMQAFnO60BJFQe0AAAAAElFTkSuQmCC" width="20">
            </a>
        </div>
        <div class="row">
            <form class="navbar-form" role="search">
                <div class="input-group">
                    <input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
                    <div class="input-group-btn">
                        <button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
                    </div>
                </div>
            </form>
        </div>
        <!--SEARCH NAVBAR-->
        <div class="row">
            <div class="dropdown">
                <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" 
                    data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                Dropdown
                <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                    <li><a href="#">Alta usuari</a></li>
                    <li><a href="#">Cerca d'usuaris</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="#">Manteniment taules mestre</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="#">Ajuda DIBA</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="#">Logout</a></li>
                </ul>
            </div>
        </div>
        <!--MENU NAVBAR-->
        <button type="button" class="collapsed navbar-toggle" data-toggle="collapse" 
            data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
            <span class="sr-only">ToggleNav</span> 
            <!--EL ICONO DE MENU, SE HACE ASI, QUE TRISTE-->
            <span class="icon-bar"></span> 
            <span class="icon-bar"></span> 
            <span class="icon-bar"></span> 
        </button>
    </div>
</nav>

在导航栏上实现某些内容的正确顺序有哪些最佳做法?非常感谢你

更新错误支架:

  

BRACKETS ERROR

我知道这不是代码错误,但会断开实时预览,当我最大化窗口时,它不会显示导航栏切换...

3 个答案:

答案 0 :(得分:3)

这是你正在寻找的一个bootply。您不想在导航栏中使用班级.row,而您确实希望使用.navbar-right的班级 http://www.bootply.com/lu9p6jQXlx#

更新了最小化导航栏的链接。你不应该使用任何css来启动bootstrap。

答案 1 :(得分:2)

要在所有屏幕尺寸中可视化您的toggle-bar,您必须使用此css代码:

.navbar-header {
  float: none;
}
.navbar-toggle {
  display: block;
}
.navbar-collapse.collapse {
  display: none!important;
}
.navbar-nav {
  float: none!important;
}
.navbar-nav>li {
  float: none;
}
.navbar-collapse.collapse.in{
  display:block !important;
}

我还在切换栏中保留了一些菜单。你可以改变/删除它。

您无需使用row

<div class="navbar-header">
    <a class="navbar-brand" href="#">B</a>
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>

    <div class="dropdown pull-right" style="margin-top:7px;">
                <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" 
                    data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                Dropdown
                <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                    <li><a href="#">Alta usuari</a></li>
                    <li><a href="#">Cerca d'usuaris</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="#">Manteniment taules mestre</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="#">Ajuda DIBA</a></li>
                    <li role="separator" class="divider"></li>
                    <li><a href="#">Logout</a></li>
                </ul>
            </div>

    <form class="navbar-form navbar-right" role="search">
        <div class="form-group input-group">
          <input type="text" class="form-control" placeholder="Search..">
          <span class="input-group-btn">
            <button class="btn btn-default" type="button">
              <span class="glyphicon glyphicon-search"></span>
            </button>
          </span>
        </div>
      </form>
  </div>

查看您想要的输出:http://www.bootply.com/obQ6W1pL81

答案 2 :(得分:0)

以下链接可能会对您的问题提供一些帮助: http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_navbar_right&stacked=h