Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fade tabs in & out with the Twitter Bootstrap framework?

jQuery UI has the option to initialize tabs with the tabs set to fade in/out, like so:

$(".selector").tabs({ fx: { opacity: 'toggle' } });

Is something similar possible with the Twitter Bootstrap framework tabs?

like image 707
Travis Northcutt Avatar asked Jan 18 '12 18:01

Travis Northcutt


People also ask

How do you add a fade in effect to tabs?

Use the . in class in Bootstrap to fade in the tab.

How set fade effect in bootstrap?

Step 1: Add bootstrap CDN to your HTML code. Step 2: For making a bootstrap carousel you have to add class = “carousel” in your HTML div box. Step 3: To create the carousel fade in and fade out transition instead of a slider you have to add a class=”carousel-fade”.


2 Answers

Both for Bootstrap 2 and 3, you can simply give your .tab-pane elements a fade class with bootstrap-transition.js loaded. No need to write a single line of your own JavaScript code at all.

<div class="tab-content">
  <div class="tab-pane fade in active" id="home">...</div>
  <div class="tab-pane fade" id="profile">...</div>
  <div class="tab-pane fade" id="messages">...</div>
  <div class="tab-pane fade" id="settings">...</div>
</div>

Code sample from the official Twitter Bootstrap documentation.

like image 162
baxang Avatar answered Sep 29 '22 13:09

baxang


No, but you could add your own, jsFiddle

$('.tabs').tabs()
    .bind('change', function (e) {
        $(this).next().hide().fadeIn();
    });
like image 30
Sinetheta Avatar answered Sep 29 '22 12:09

Sinetheta