在样式div中放置引导菜单

时间:2018-06-04 21:29:07

标签: css html5 twitter-bootstrap css3 navbar

我有一个带有CSS样式和引导菜单的div。我想知道如何将该菜单与css合并在同一个div中,并得到类似的内容:

关于我们 - 历史质量

我想添加文本“关于我们”,然后使用nav将菜单与第一个文本联系起来。我怎样才能做到这一点?此致

目前有一个Fiddle菜单和样式div

HTML:

<div class="titulo" width:="100px" height:="30px" style="text-align:left;">ABOUT US</div>

<nav class="navbar navbar-default" role="navigation">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-sidebar-navbar-collapse-1">
                                    <span class="sr-only">Toggle navigation</span>
                                    <span class="icon-bar"></span>
                                    <span class="icon-bar"></span>
                                    <span class="icon-bar"></span>
                                </button>
    </div>
    <div class="collapse navbar-collapse" id="bs-sidebar-navbar-collapse-1">
      <ul class="nav navbar-nav .font_black">
        <li>
          <a class="font_black" href="#office">HISTORY
                                            <span style="font-size:16px;" class="pull-right hidden-xs showopacity"></span>
                                        </a>
        </li>
        <li>
          <a class="font_black" href="#group">QUALITY
                                            <span style="font-size:16px;" class="pull-right hidden-xs showopacity"></span>
                                        </a>
        </li>
        <li>
          <a class="font_black" href="#global">GLOBAL PRESENCE
                                            <span style="font-size:16px;" class="pull-right hidden-xs showopacity"></span>
                                        </a>
        </li>
        <li>
          <a class="font_black" href="#clients">CLIENTS AND AWARDS
                                            <span style="font-size:16px;" class="pull-right hidden-xs showopacity"></span>
                                        </a>
        </li>
        <li>
          <a class="font_black" href="#sustent">SUSTENTABILITY
                                            <span style="font-size:16px;" class="pull-right hidden-xs showopacity"></span>
                                        </a>
        </li>
        <li>
          <a class="font_black" href="#legal">LEGAL
                                            <span style="font-size:16px;" class="pull-right hidden-xs showopacity"></span>
                                        </a>
        </li>
      </ul>
    </div>
  </div>
</nav>

CSS:

.titulo {
  height: 40px;
  padding: 0 0 0 25px;
  font-size: 20px;
  font-weight: 600;
  background-color: #0039a6;
  text-transform: uppercase;
  color: #ffffff;
  line-height: 40px;
}

1 个答案:

答案 0 :(得分:0)

两件事:

  1. 考虑使用Navbar Brand并相应地设置它的样式而不是单独的样式div

  2. 根据BS3文档,BS导航栏无法知道您的菜单项有多大,因此会根据需要进行换行

  3.   

    溢出内容

         

    由于Bootstrap不知道导航栏中的内容需要多少空间,因此您可能会遇到内容包装到第二行的问题。要解决此问题,您可以:

         
        
    • 减少导航栏项目的数量或宽度。
    •   
    • 使用自适应实用程序类隐藏某些屏幕尺寸的某些导航栏项目。
    •   
    • 更改导航栏在折叠模式和水平模式之间切换的点。自定义@ grid-float-breakpoint变量或添加自己的媒体查询。
    •   

    代码段:切换到全屏查看

    &#13;
    &#13;
    .navbar-brand {
      background-color: blue;
      color: white !important;
    }
    
    ul.nav.navbar-nav li a {
      text-transform: uppercase;
    }
    &#13;
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <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>
    
    
    <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="#">About Us</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 class="active"><a href="#">History</a></li>
            <li><a href="#">Quality</a></li>
            <li><a href="#">Global Presence</a></li>
            <li><a href="#">Clients</a></li>
            <li><a href="#">Sustentability</a></li>
            <li><a href="#">Legal</a></li>
          </ul>
        </div>
      </div>
    </nav>
    &#13;
    &#13;
    &#13;