删除导航栏下的空间(Bootstrap)

时间:2015-08-13 19:20:05

标签: css twitter-bootstrap navbar

我正在尝试删除导航栏和菜单下的图片之间的空间。

我尝试使用margin-top / margin-bottom而且我还试图在bootstrap.min.css中编辑.navbar {margin-bottom:20px;},但这也无济于事。

我的HTML代码如下所示               

    <div class="col-sm-3">
        <div class="logo"><a href="Index.php"> <img src="http://localhost/wordpress/wp-content/themes/Greenterapi/Pics/Logo.png" alt="Home" width="200px" height="74px"></a></div>
    </div>

    <div class="col-sm-9">
        <nav class="navbar navbar-static-top" role="navigation">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                        <span class="sr-only">Toggle navigation</span>
                        <div class="btn btn-primary">Menu</div>
                    </button>

                </div>

                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li class="active"><a href="Index.php">Home</a></li>
                        <li><a href="Om.php">Om mig</a></li>
                        <li><a href="Coaching.php">Coaching</a></li>
                        <li><a href="Psykoterapi.php">Psykoterapi</a></li>
                        <li><a href="Zoneterapi.php">Zoneterapi</a></li>
                        <li><a href="Erhverv.php">Erhverv</a></li>
                        <li><a href="Priser.php">Priser</a></li>
                    </ul>
                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav> </div>


    </div>






<!--Row with 1 column in 1:1 ratio-->
<div class="row">
    <div class="col-sm-12">
            <div class="Header"><img src="http://placehold.it/1140x250"></div>
    </div>

</div>

我没有任何影响菜单或图片的css代码,除了这个

ul.nav a:hover { background-color: #555; color: #030303 !important; }

我希望你能帮忙,我没有想法。

根据请求

修改 http://codepen.io/anon/pen/vOMRGV

编辑2 似乎正在使用br标签和margin-bottom感谢大家的帮助。

3 个答案:

答案 0 :(得分:2)

这是一个有效的版本:http://codepen.io/anon/pen/ZGZxOB。看起来它必须是后来在CSS中将margin-bottom设置重置为20px的其他东西,如果你在更改bootstrap的CSS中的边距后仍然看到间隙。

您应该通过按键盘上的F12在任何主要浏览器中使用元素检查器。然后,您可以检查元素并查看影响.navbar的所有CSS规则。

答案 1 :(得分:1)

这可能有所帮助。

body {
  background-color: #ECECEA;
}
div.haj {
  background-color: #ff390d;
}
div.InfoTekst,
div.Info {
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 5px;
  margin-top: 20px;
  min-height: 100px;
  font-size: 16px;
  background-color: rgba(255, 255, 255, 0.5);
}
ul.nav a:hover {
  background-color: #555;
  color: #030303 !important;
}
.navbar.navbar-static-top {
  margin-bottom: 0px;
  padding-right: 15px;
}
.navbar.navbar-static-top,
.navbar-nav li a {
  height: 74px;
}
#brand-logo {
  background-size: contain;
  position: absolute;
  min-width: 200px;
}
#brand-logo img {
  width: 100%;
  height: 74px;
}
.navbar-static-top .navbar-brand {
  display: none;
}
@media (max-width: 768px) {
  .navbar-static-top .navbar-nav {
    background: #ECECEA;
  }
  .navbar .navbar-header .navbar-toggle {
    margin-bottom: 0px;
  }
  .navbar-static-top .navbar-nav li a {
    height: auto;
  }
  .navbar.navbar-static-top {
    height: 74px;
    padding-right: 0;
  }
}
#brand-logo img {
  width: 200px;
  height: 74px;
}
@media (max-width: 992px) and (min-width: 768px) {
  .navbar-static-top .navbar-nav li {
    font-size: 11px;
  }
}
<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.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <div class="row">
    <div class="col-md-2 col-sm-2">
      <div id="brand-logo">
        <a href="Index.php">
          <img src="http://placehold.it/200x74/555/fff?text=Home" alt="Home" />
        </a>

      </div>
    </div>
    <div class="col-md-10 col-sm-10">
      <nav class="navbar navbar-static-top" role="navigation">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse"> <span class="sr-only">Toggle navigation</span>

            <div class="btn btn-primary">Menu</div>
          </button>
        </div>
        <div class="collapse navbar-collapse" id="navbar-collapse">
          <ul class="nav navbar-nav navbar-right">
            <li class="active"><a z href="Index.php">Home</a>

            </li>
            <li><a href="Om.php">Om mig</a>

            </li>
            <li><a href="Coaching.php">Coaching</a>

            </li>
            <li><a href="Psykoterapi.php">Psykoterapi</a>

            </li>
            <li><a href="Zoneterapi.php">Zoneterapi</a>

            </li>
            <li><a href="Erhverv.php">Erhverv</a>

            </li>
            <li><a href="Priser.php">Priser</a>

            </li>
          </ul>
        </div>
      </nav>
    </div>
  </div>
  <!--Row with 1 column in 1:1 ratio-->
  <div class="header">
    <img src="http://placehold.it/1140x250/f00/fff" class="img-responsive">
  </div>
  <!--Row with two columns divided in 1:3 ratio-->
  <div class="row">
    <div class="col-sm-9">
      <div class="row">
        <div class="col-sm-12">
          <div class="InfoTekst">
            <p>
              <h3>Velkommen til Green Terapi</h3> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
              aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
          </div>
        </div>
        <div class="col-sm-12">
          <div class="InfoTekst">
            <p>
              <h3>Coaching</h3> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
              aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
          </div>
        </div>
        <div class="col-sm-12">
          <div class="InfoTekst">
            <p>
              <h3>Psykoterapi</h3> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
              aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
          </div>
        </div>
        <div class="col-sm-12">
          <div class="InfoTekst">
            <p>
              <h3>Zoneterapi</h3> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
              aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-3 text-center">
      <div class="Info">
        <p>
          <p class="Billede">
            <img src="http://localhost/wordpress/wp-content/themes/Greenterapi/profile.jpg" alt="Logo" style="width:160px;height:160px">
          </p>
          <h5>
                    Coach
                </h5>

          <h5>
                    Psykoterapeut
                </h5>

          <h5>
                    Zoneterapeut
                </h5>

          <p>Jeanette Green</p>
          <p>Tlf.: 22 11 26 39</p>
          <br>
          <p> <b>
                        mail@green-terapi.dk
                    </b>

          </p>
          <p>Motion & Sundhedshuset
            <br>Egedal 15
            <br>2690 Karlslunde</p>
        </p>
      </div>
    </div>
  </div>
</div>

答案 2 :(得分:0)

您可能需要检查ul和a的默认设置。可能有边距,填充,您需要覆盖导航栏部分。