Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove space between navbar and jumbotron in Bootstrap 3

There is space between my navbar and the jumbotron in bootstrap 3. There is also space between the jumbotron and 3 horizontal thumbnails. I want to get rid of this space. Do I have to change the CSS and change the padding or what is the best way?

_Header

<nav class="navbar navbar-inverse" role="navigation">
  <!-- Brand and toggle get grouped for better mobile display -->
  <div class="navbar-header">
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
      <span class="sr-only">Toggle navigation</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
    <div style="font-family:Webdings;">
      <%= link_to "Project", root_path, class: 'navbar-brand' %>
    </div>
  </div>

  <!-- Collect the nav links, forms, and other content for toggling -->
  <div class="collapse navbar-collapse navbar-ex1-collapse">
    <ul class="nav navbar-nav">
      <li class="active"><%= link_to "About", about_path %></li>
      <li><%= link_to "Team", team_path %></li>
      <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Resources<b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li><%= link_to "Action 1", about_path %></li>
          <li><%= link_to "Action 2", about_path %></li>
          <li><%= link_to "Action 3", about_path %></li>
          <li><%= link_to "Action 4", about_path %></li>
        </ul>
      </li>
    </ul>
    <ul class="nav navbar-nav navbar-right">
      <li><%= link_to "Contact", contact_path %></li>
      <li><%= link_to "Sign Up", register_path %></li>
    </ul>
  </div><!-- /.navbar-collapse -->
</nav

Home (with thumbnails)

<%= provide(:title, "Home") %>
<div class="jumbotron">
  <div class="container">
    <h1>Welcome to club!</h1>
    <p>blabla</p>
    <p><a class="btn btn-primary btn-lg">Sign Up</a></p>
  </div>
</div>


<div class="column">
  <div class="col-xs-4">
    <div class="thumbnail">
      <img src="http://b2bleadblog.com/images/2007/05/18/huddlehands.jpg" alt="My Image" />
      <div class="caption">
        <h3>Blablabla</h3>
        <p style="font-size:17px">Blablalbal.</p>
      </div>
    </div>
  </div>
</div>
like image 452
megashigger Avatar asked Aug 23 '13 19:08

megashigger


People also ask

How do I reduce the space between Navbars?

Your Navbar class should change to navbar-nav and margin-left should be auto to set your navbar float left by ml-auto . Or Use Flex Box I add to your CSS file which is Commented for the container. For Spacing between items, you can use margin-right in your CSS file.

How can I remove space between two containers in Bootstrap?

To make it more clear, bootstrap assigns margin-left: -15px and margin-right: -15px for . row selector and padding-left: 15px and padding-right: 15px on all . col-* selectors to get 30px space between all the cols. To remove this space, you have to set those values for margins and paddings to zero.

What replaced jumbotron in Bootstrap?

In Bootstrap 5 the jumbotron component is removed in favor of utility classes like . bg-light for the background color and .


1 Answers

You have to set margin-bottom:0; to navbar and jumbotron classes. You can use a custom stylesheet to override this. Use custom CSS next to the bootstrap css reference. as below:

  <link href="../css/bootstrap.css" rel="stylesheet" type="text/css" /> 
  <link href="../css/CustomStyles.css" rel="stylesheet" type="text/css" />

See this bootply example

like image 101
Ravimallya Avatar answered Sep 28 '22 07:09

Ravimallya