顶部带有公司徽标的bootstrap导航栏

时间:2017-09-07 03:15:43

标签: css angularjs twitter-bootstrap twitter-bootstrap-3

我正在使用bootstrap创建一个angular 2应用程序。我希望在我的应用程序上有一个导航栏,以便应用程序菜单看起来像enter image description here

从较小的设备查看时,它应如下所示: enter image description here

我在html中使用了以下代码

<nav class="navbar navbar-inverse">
    <div class="container">
        <div class="navbar-header" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
            <button type="button" class="navbar-toggle">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">COMPANY LOGO</a>
        </div>
        <div class="navbar-collapse collapse sidebar-navbar-collapse">
            <ul *ngFor="let menu of menus;let first = first;" class="nav navbar-nav">
                <li>
                    <a (click)="menuClicked(menu.categoryId)"
                       href='#/{{menu.categoryName}}'
                       style="color: #fff;font-size: 16px;font-weight:bold;cursor:pointer;">
                        {{menu.categoryName}}
                    </a>
                </li>
            </ul>
        </div>
    </div>
</nav>

这给了我以下输出:

enter image description here

有人可以指导如何实现所需的输出吗?

2 个答案:

答案 0 :(得分:2)

@Mandar Patil,我已经与符合您要求的codeply project相关联。

对于折叠导航菜单上的品牌,您只需使用bootstraps visiblehidden实用程序类,并指定相应的断点。

HTML

<div class="container hidden-xs visible-sm visible-md visible-lg">
    <div class="row">
        <div class="col-12">
            <a class="navbar-brand" href="#">COMPANY LOGO</a>
        </div>
    </div>
</div>

...

       <div class="navbar-header" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
            <button type="button" class="navbar-toggle">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand visible-xs hidden-sm hidden-md hidden-lg" href="#" style="color: white;">COMPANY LOGO</a>
        </div>

答案 1 :(得分:1)

你可以试试这个:

<nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>                        
      </button>
      <div class="col-md-12 clearfix">
      <div class="row"> 
      <a class="navbar-brand" href="#">WebSiteName</a>
      </div>
      </div>
    </div>

    <div class="col-md-12 clearfix"> 
    <div class="row">
    <div class="collapse navbar-collapse" id="myNavbar">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Page 1-1</a></li>
            <li><a href="#">Page 1-2</a></li>
            <li><a href="#">Page 1-3</a></li>
          </ul>
        </li>
        <li><a href="#">Page 2</a></li>
        <li><a href="#">Page 3</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
        <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
      </ul>
    </div>
    </div>
    </div>

  </div>