nav和jumbotron之间的差距在bootstrap中

时间:2014-06-21 02:34:34

标签: html css twitter-bootstrap web

对于我的生活,我无法确定我的导航和大腕之间的空白来自哪里,我玩过很多变量,但是不能让它消失。我在这里做了一个cssdeck http://cssdeck.com/labs/u6ws0ozl,我的代码在下面(省略了Bootstrap代码)。

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="shift.css" rel="stylesheet">
<link href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/bootstrap.css" rel="stylesheet" />
<link href="style.css" rel="stylesheet" />
</head>

<body>
<nav class="navbar navbar-static-top" role="navigation">
  <div class="container-fluid">
    <!-- Collect the nav links, forms, and other content for toggling -->
    <!-- <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> -->
      <ul class="nav nav-pills pull-left">
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#">About Us</a></li>
      </ul>
      <form class="navbar-form navbar-right navbar-custom pull-right" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search">
        </div>
        <button type="submit" class="btn btn-default">Submit</button>
      </form>
      <ul class="nav nav-pills pull-right">
        <li><a href="#">Log In</a></li>
        <li><a href="#">Help</a></li>
      </ul>
    <!-- </div> /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
<div class="jumbotron">
      <div class="container">
        <h1>Find a place to stay.</h1>
        <p>Rent from people in over 34,000 cities and 192 countries.</p>
        <a href="#">Learn More</a>
      </div>
    </div> 
</body>
</html>

CSS:

@charset "UTF-8";
/* CSS Document */

.navbar {
    background-color: #2c3e50;
}

.nav-pills {
    padding-top: 20px;
    padding-bottom: 20px;
    padding-right: 15px;
    padding-left: 15px;
    /*background-color: #2c3e50;*/
    /*background-color: #2ecc71;*/
}

.nav > li > a:hover,
.nav > li > a:focus {
  text-decoration: none;
  background-color: #2ecc71;
}

.nav-pills > li.active > a,
.nav-pills > li.active > a:hover,
.nav-pills > li.active > a:focus {
  color: #fff;
  background-color: #2ecc71;
}

.navbar-custom {
    padding-top: 20px;
}

.nav a {
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  font-family: 'Shift', sans-serif;
  /*padding: 14px 14px;*/
  text-transform: uppercase;
}

.nav li {
  display: inline;
}

.jumbotron {
  background-image:url('http://goo.gl/04j7Nn');
  height: 500px;
}

.jumbotron .container {
  margin-top: 0px;
  position: relative;
  top:100px;
}

.jumbotron h1 {
  color: #fff;
  font-size: 48px;  
  font-family: 'Shift', sans-serif;
  font-weight: bold;
}

.jumbotron p {
  font-size: 20px;
  color: #fff;
}

.learn-more {
  background-color: #f7f7f7;
}

.learn-more h3 {
  font-family: 'Shift', sans-serif;
  font-size: 18px;
  font-weight: bold;
}

.learn-more a {
  color: #00b0ff;
}

.neighborhood-guides {
    background-color: #efefef;
    border-bottom: 1px solid #dbdbdb;
}

.neighborhood-guides h2 {
    color: #393c3d;
    font-size: 24px;
}

.neighborhood-guides p {
    font-size: 15px;
    margin-bottom: 13px;
}

2 个答案:

答案 0 :(得分:6)

从css / bootstrap.css

中删除以下内容
.navbar{
   margin-bottom: 20px;
}

或者您也可以通过将margin:0;添加到您自己的css文件来覆盖它:

.navbar {
    background-color: #2c3e50;
    margin:0; /*add this*/
}

Live demo

答案 1 :(得分:0)

你必须删除

.jumbotron{

    margin-bottom:20px;
          }

如果您的布局是:
超大屏幕
(GAP)
导航栏
然后单独删除.navbar边距将无法达到预期效果.jumbotron有margin-bottom:20px;