即使在使用单独的<div>之后,在jumbotron和navbar之间也没有空格

时间:2016-05-12 19:56:23

标签: html twitter-bootstrap

您可以在下方找到导航栏和jumbotron div。我已经使用过bootstrap,但经过多次努力尝试纠正代码后,我找不到问题。

    <body>

        <div>
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                                <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="#">Ankur Chavda</a>
                </div>
                <div id="navbar" class="navbar-collapse navbar">
                    <ul class="nav navbar-nav">
                        <li class="active"><a href="#"><span class="glyphicon glyphicon-home" aria-hidden="true"></span> Home</a></li>
                        <li class=""><a href="#"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> About</a></li>
                        <li class=""><a href="#"><i class="fa fa-envelope-o"></i> Contact</a></li>
                    </ul>
                </div>
            </div>

        </nav>
        </div>

>Jumbotron
            <div class="jumbotron">    //jumbotron
                <div class="container">
                <div class="row">
                    <p>hello</p>
                </div>
                </div>
            </div>
        </body>

2 个答案:

答案 0 :(得分:0)

类.navbar的元素具有20px的底部边距。将其删除:

.navbar {
  margin-bottom:0;
}

<强> bootply example

答案 1 :(得分:0)

我清理了你的代码,并在导航栏和jumbotron之间增加了空间。

<!DOCTYPE html>
<html>
 <head>
   <link rel="stylesheet"href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
   <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
 </head>
 <body>

    <div>
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
                            <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="#">Ankur Chavda</a>
            </div>
            <div id="navbar" class="navbar-collapse navbar">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#"><span class="glyphicon glyphicon-home" aria-hidden="true"></span> Home</a></li>
                    <li class=""><a href="#"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> About</a></li>
                    <li class=""><a href="#"><i class="fa fa-envelope-o"></i> Contact</a></li>
                </ul>
            </div>
        </div>

    </nav>
    </div><br><br><br>


<!--Here <br> is used for giving space between the navigation bar and jumbotron-->

<!-- Jumbotron -->
<div class="container">
        <div class="jumbotron">   

            <div class="row">
                <p>hello</p>
            </div>
            </div>
        </div>
    </body>
</html>