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>
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.
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.
In Bootstrap 5 the jumbotron component is removed in favor of utility classes like . bg-light for the background color and .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With