为什么我的bootstrap navbar品牌不内联 [英] Why is my bootstrap navbar brand not inline

查看:78
本文介绍了为什么我的bootstrap navbar品牌不内联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <!DOCTYPE html>< html lang =en> < head> < meta charset =utf-8> < meta http-equiv =X-UA-Compatiblecontent =IE = edge> < meta name =viewportcontent =width = device-width,initial-scale = 1> <! - 上述3个元标记*必须首先在头部;任何其他头部内容必须来*后*这些标签 - > < title> Bootstrap 101 Template< / title> <! -  Bootstrap  - > < link href =css / bootstrap.min.css =stylesheet> <! -  HTML5 shim和Respond.js for IE8对HTML5元素和媒体查询的支持 - > <! - 警告:如果您通过file://  - >查看页面,Respond.js不起作用。 <! -  [if lt IE 9]> < script src =https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js>< / script> < script src =https://oss.maxcdn.com/respond/1.4.2/respond.min.js>< / script> <![endif]  - > < style> < / style> < / head>< body>< div class =navbar navbar-default> < div class =container> < div class =navbar-header> < button class =navbar-toggledata-toggle =collapsedata-target =navbar-collapse> < span class =icon bar>< / span> < span class =icon bar>< / span> < span class =icon bar>< / span> < / button> < a class =navbar-brandhref =#> MyBinge< / a> < / div> < div class =collapse navbar-collapse> < / div> < ul class =nav navbar-nav> < li class =active>< a href =#>开始使用< / a>< / li> < li>< a href =#>告诉我们< / a>< / li& < li>< a href =#>关于此项目< / a>< / li>< / ul> < / div>< / div><! - 最新编译和缩小的JavaScript  - >< script src =https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap。 min.jsintegrity =sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xScrossorigin =anonymous>< / script>< / body>< / html>  

>



我想知道为什么我的navbar品牌不符合导航栏内容的其余部分。我已经尝试过这篇文章中的解决方案为什么我的引导导航栏不显示在线?



提前谢谢! :)

解决方案

不要关闭ul之前的div。以类似.nav .navbar-nav的形式包含ul。



  div class =collapse navbar-collapse> < ul class =nav navbar-nav> < li class =active>< a href =#>开始使用< / a>< / li> < li>< a href =#>告诉我们< / a>< / li& < li>< a href =#>关于此项目< / a>< / li> < / ul>< / div>  


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <style>


    </style>
  </head>


<body>


<div class="navbar navbar-default">

  <div class="container">

    <div class="navbar-header">
        <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>

      <a class="navbar-brand" href="#">MyBinge</a>
    </div>

    <div class="collapse navbar-collapse">

    </div>

 <ul class="nav navbar-nav">
      <li class="active"><a href="#">get started</a></li>
      <li><a href="#">tell us</a></li>
      <li><a href="#">about this project</a></li>
</ul>




  </div>
</div>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>


</body>

</html>

I'm trying to figure out why my navbar brand is not in line with the rest of the navbar content. I already tried the solutions in this post Why is my bootstrap navbar not displaing inline?

Thank you in advance! :)

解决方案

Don't close the div before the ul. Include the ul with class .nav .navbar-nav like this

<div class="collapse navbar-collapse">
  <ul class="nav navbar-nav">
     <li class="active"><a href="#">get     
       started</a></li>
      <li><a href="#">tell us</a></li>
      <li><a href="#">about this project</a></li>
  </ul>
</div>

 

这篇关于为什么我的bootstrap navbar品牌不内联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆