Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove top of page space from Bootstrap

In my code, I have a persistent gap at the very top of my page that appears to be set to the tag by Bootstrap. I have searched via Firefox's inspector and have found nothing. Trying to add margin: 0; padding: 0; to the tag has done nothing either.

The #intro div here should be right at the top, but the space appears above it.

<body>

        <div id="intro" style="width: 100%; padding:0; margin:0; text-align:center;">
            <h2>Test</h2>
        </div>

        <nav class="navbar navbar-default" role="navigation" style="margin: 0; opacity: 0.95;">
          <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <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="#" id="brand-mobile">Map My Cash</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1" style="text-align: center;">
              <ul class="nav navbar-nav" id="navbar-media-query" style="float: none; display: inline-block;">
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
                  <ul class="dropdown-menu">
                    <li><a href="#">Action</a></li>
                  </ul>
                </li>
              </ul>
            </div><!-- /.navbar-collapse -->
          </div><!-- /.container-fluid -->
        </nav>

        @RenderBody()

    </body>
like image 955
user3761858 Avatar asked Jun 21 '14 21:06

user3761858


2 Answers

You will have to override the default css.

Add following CSS after the default bootstrap CSS you are using:

body{
   padding-top:0px;
   margin-top: 0px;
}
like image 100
writeToBhuwan Avatar answered Sep 21 '22 18:09

writeToBhuwan


Got it! The h1 was the problem. I added:

h1 {
    margin-top: 0;
}

No-gap at the top of the page anymore!

like image 36
Amir Eldor Avatar answered Sep 23 '22 18:09

Amir Eldor