Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap tabs with margins

I have a web application and this is using Bootstrap tabs. See below for the image enter image description here

I wanted to ensure that there is some whitespace/margin in between the tab and the text

 <div class="row">
    <div class="col-lg-12">
       <h2 class="page-header">More information</h2>
    </div>
    <div class="col-lg-12">
      <ul id="myTab" class="nav nav-tabs nav-justified">
        <li class="active "><a href="#tab-one" data-toggle="tab"><i class="fa fa-tree"></i>Images</a></li>
        <li class=""><a href="#tab-two" data-toggle="tab"><i class="fa fa-car"></i>Full Description</a></li>
        <li class=""><a href="#tab-three" data-toggle="tab"><i class="fa fa-car"></i>Details</a></li>
      </ul>

    <div id="myTabContent" class="tab-content margin-bottom">
      <div class="tab-pane fade active in" id="tab-one">
          <p>Here comes the pictures</p>
      </div>

      <div class="tab-pane fade" id="tab-two">
          <p>Here comes the large description</p>
      </div>
     .......
     .......

I have tried with defining the following in my CSS file:

.margin-bottom{
  margin-bottom: 1.25rem  !important ;
}

and then apply that style to the different classes of the first snippet, but can't get it to work. Any suggestions welcome!

like image 492
wiwa1978 Avatar asked Mar 26 '26 11:03

wiwa1978


1 Answers

You're trying to update the bottom margin of the content. You should be either adjust the top margin, or the bottom margin of the actual tabs. So either:

#myTabContent {
  margin-top: 1.25rem;
}

Or:

#myTab {
  margin-bottom: 1.25rem;
}

(Of course, modify the selectors as you see fit)

This is because margin-bottom is the space between the bottom of the current element and the one below it. Margin top would push the current element down a bit, margin-bottom would push the one below it, lower.

like image 137
casraf Avatar answered Apr 01 '26 06:04

casraf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!