Nav Tabs inside Carousel breaks Carousel
Nav Tabs inside Carousel breaks Carousel. its due to active class in both Carousel and tabs
I will upload an example here soon.
Currently the carousel doesn't support tabs, or any other component, within it. We'll swing back around to this in a future release.
Carousel inside tabs doesn't work either.
the carousel in the first active tab works, but once the tab is off and on again, the carousel stops working
I've encountered this too.
to make carousels work inside tabs you need to change the CSS of the tabs
by default, tab-pane has a display:none style that confuses the carousel (as its container has no dimensions)
if you change your tab-pane styles to:
display: block; position: relative; left: -10000px;
and your .tab-pane.active styles to:
left: 0;
it should work. it works for me
El problema es que el carousel se reproduce al estar el tab oculto, se debe detener para evitar el error.
The problem is that the carousel plays the tab to be hidden, must be stopped to avoid the error.
$(document).ready(function() {
$('a[data-toggle="tab"]').on('shown', function (e) {
switch(e.currentTarget.hash){
case '#tab0':
$('#myCarousel1').carousel('pause')
$('#myCarousel2').carousel('pause')
$('#backMenu').css('background-image','url("./img/back0.png")');
break;
case '#tab1':
$('#myCarousel0').carousel('pause')
$('#myCarousel2').carousel('pause')
$('#backMenu').css('background-image','url("./img/back1.png")');
break;
case '#tab2':
$('#myCarousel0').carousel('pause')
$('#myCarousel1').carousel('pause')
$('#backMenu').css('background-image','url("./img/back2.png")');
break;
}
})
The real problem is that the TAB searches for a .active class and just deletes it from the elements it finds. The selector used to get the active tab should be more specific to only get the .active element that is a direct descendant of the tabs container.
if you don't set interval and the carousel is used once change to autoplay. You can test this in a simple carousel. When change item on a hidden tab the class .next, .prev asigned to item div broken the carousel.
@heronog your css fix didn't work for me because it was stacking the tab-pane elements on top of each other. What I did to fix this was changed the css to the following:
.tab-content > .tab-pane,
.pill-content > .pill-pane {
position: absolute;
opacity: 0;
z-index:0;
}
.tab-content > .active,
.pill-content > .active {
opacity: 1;
z-index:1;
}
Cool. that works too but.
I just think that changing the opacity of an element to 0 makes it invisible but it's still clickable, so make sure you move the active tab pane to the front to avoid "ghost" elements from the other panes
Yeah that's why I added the z-index.
using z-index solved my problem too. Earlier when using tabs with display block/none other tabs except first tab din't worked.