如何消除导航栏项目与导航栏底部之间的差距?

时间:2017-06-29 15:52:21

标签: html css navigation navbar

<!--NAVBAR-->
            <nav class="navbar navbar-inverse">
                <div class="container">
                    <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>
                    <div class="collapse navbar-collapse" id="myNavbar">
                        <ul class="nav navbar-nav">
                            <li class="active"><a href="#">Home</a></li>
                            <li><a href="#">Page 1</a></li>
                            <li><a href="#">Page 2</a></li>
                            <li class="navfixborder"><a href="#">Page 3</a></li>
                        </ul>
                    </div>
                </div>
            </nav>

我的CSS,css是基本的bootstrap,这是我编辑的唯一类。

  .navbar-nav {
    margin: 0;
    text-align: center;
    font-size: .9em;
    width:100%;
    font-weight: bold;
    text-transform: uppercase;
    font-family: Roboto, 'Open Sans', Arial;   }   
  .navbar-nav > li {
    float: none;
    display: inline-block;
    margin-left: -5px;
    border-left: 2px solid #333240;

  }   .navbar-nav > li > a {
    padding-top: 10px;
    padding-bottom: 10px;
    padding-right: 45px;
    padding-left: 45px;   }

Navbar gap image 我怎么能从导航栏的底部删除那个间隙?

4 个答案:

答案 0 :(得分:0)

将以下内容添加到您的css:

.navbar {
  min-height: 0;
}

这是我设置的CodePen: https://codepen.io/CapySloth/pen/LLQNEG

答案 1 :(得分:0)

Bootstrap适用.navbar { min-height: 50px; }。只需使用min-height: 0;

覆盖该内容即可

&#13;
&#13;
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<style>
.navbar-nav {
  margin: 0;
  text-align: center;
  font-size: .9em;
  width: 100%;
  font-weight: bold;
  text-transform: uppercase;
  font-family: Roboto, 'Open Sans', Arial;
}
.navbar-nav > li {
  float: none;
  display: inline-block;
  margin-left: -5px;
  border-left: 2px solid #333240;
}
.navbar-nav > li > a {
  padding-top: 10px;
  padding-bottom: 10px;
  padding-right: 45px;
  padding-left: 45px;
}

.navbar {
  min-height: 0;
}
</style>

<nav class="navbar navbar-inverse">
  <div class="container">
    <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>
    <div class="collapse navbar-collapse" id="myNavbar">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#">Page 1</a></li>
        <li><a href="#">Page 2</a></li>
        <li class="navfixborder"><a href="#">Page 3</a></li>
      </ul>
    </div>
  </div>
</nav>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

Bootstrap为min-height: 50px类设置.navbar。解决方案是将min-height设置为零:

.navbar {
  min-height: 0;
}

答案 3 :(得分:-2)

我添加了基础知识,但似乎没有任何问题。 enter image description here

&#13;
&#13;
.navbar-nav {
    margin: 0;
    text-align: center;
    font-size: .9em;
    width:100%;
    font-weight: bold;
    text-transform: uppercase;
    font-family: Roboto, 'Open Sans', Arial;   }   .navbar-nav > li {
    float: none;
    display: inline-block;
    margin-left: -5px;
    border-left: 2px solid #333240;

  }   .navbar-nav > li > a {
    padding-top: 10px;
    padding-bottom: 10px;
    padding-right: 45px;
    padding-left: 45px;   }
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<nav class="navbar navbar-inverse">
           <div class="container">
               <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>
               <div class="collapse navbar-collapse" id="myNavbar">
                   <ul class="nav navbar-nav">
                       <li class="active"><a href="#">Home</a></li>
                      <li><a href="#">Page 1</a></li>
                       <li><a href="#">Page 2</a></li>
                       <li class="navfixborder"><a href="#">Page 3</a></li>
                   </ul>
               </div>
           </div>
       </nav>
&#13;
&#13;
&#13;