Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Tabs Upside Down

I have used Twitter Bootstrap (http://twitter.github.io/bootstrap/javascript.html#tabs) Tabs feature, but I want it to be upside down, with Content shown on the Top and the TabMenuNav at the bottom! Is this possible? Any workarounds?

like image 782
Kelvin Castelino Avatar asked Jun 06 '13 11:06

Kelvin Castelino


2 Answers

Use the following CSS to get what you expected. I added border to .tab-content class to get the content highlighted.

.tab-content {
padding:10px;
border:1px solid #ddd;
border-bottom:0px;
}
.nav-tabs {
border-bottom: 0px;
border-top: 1px solid #ddd;
}
.nav-tabs > li {
margin-bottom:0;
margin-top:-1px;
}

.nav-tabs > li > a {
padding-top: 8px;
padding-bottom: 8px;
line-height: 20px;
border: 1px solid transparent;
-moz-border-radius:0px;
-webkit-border-radius:0px;
border-radius:0px;
-moz-border-radius-bottomright: 5px;
-webkit-border-bottom-right-radius: 5px;
border-bottom-right-radius: 5px;
-moz-border-radius-bottomleft: 5px;
-webkit-border-bottom-left-radius: 5px;
border-bottom-left-radius: 5px;
}
.nav-tabs > .active > a, .nav-tabs > .active > a:hover, .nav-tabs > .active > a:focus {
color: #555555;
cursor: default;
background-color: #ffffff;
border: 1px solid #ddd;
border-top-color: transparent;
}

The HTML structure should be like this:

<div class="tabbable">
    <div class="tab-content">
        <div id="tab1" class="tab-pane active">
            tab1 content</div>
        <div id="tab2" class="tab-pane">
            tab2 content</div>
        <div id="tab3" class="tab-pane">
            tab3 content</div>
        <div id="tab4" class="tab-pane">
            tab4 content</div>
    </div>
    <ul class="nav nav-tabs">
        <li class="active"><a href="#tab1" data-toggle="tab">tab1</a></li>
        <li><a href="#tab2" data-toggle="tab">tab2</a></li>
        <li><a href="#tab3" data-toggle="tab">tab3</a></li>
        <li><a href="#tab4" data-toggle="tab">tab4</a></li>
    </ul>
</div>

Bootply example.

like image 57
Ravimallya Avatar answered Sep 19 '22 15:09

Ravimallya


For those arriving looking for a solution for Bootstrap 4.

Bootstrap used to have tabs-below class to achieve this. But it was removed in version 3.

I "restored" this feature in the following code. You just need to add tabs-below class to your ul element. Check https://jsfiddle.net/oniltonmaciel/nhfrz2bc/ for the full solution.

css:

.tabs-below {
  border-bottom-width: 0px;
  border-top: 1px solid #dee2e6;
}

.tabs-below .nav-link {
    border: 1px solid transparent;
    border-top-left-radius: 0px;
    border-top-right-radius: 0px;
    border-bottom-left-radius: .25rem;
    border-bottom-right-radius: .25rem;
}

.tabs-below .nav-item {
  margin-bottom: 0px;
  margin-top: -1px;
}

.tabs-below .nav-item.show .nav-link, .tabs-below .nav-link.active {
  border-color: #fff #dee2e6 #dee2e6  #dee2e6;
}

html:

  <div class="tab-content" id="myTabContent">
    <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab"><p>Contents of tab 1</p></div>
    <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab"><p>Contents of tab 2</p></div>
    <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab"><p>Contents of tab 3</p></div>
  </div>
  <ul class="nav nav-tabs tabs-below" id="myTab" role="tablist">
    <li class="nav-item">
      <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a>
    </li>
    <li class="nav-item">
      <a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Contact</a>
    </li>
  </ul>
like image 43
Onilton Maciel Avatar answered Sep 19 '22 15:09

Onilton Maciel