Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Carousel: have carousel-indicators outside Carousel Div

Is it possible to have the carousel-indicators list outside the Carousel Div? And at the bottom, I'm asking if it's possible to search the entire page for specific elements with a class tied to them.

I'm imagining something like this:

<div id="presentation" class="tab-pane active">
    <div id="presentationCarousel" class="carousel slide">
        <div class="carousel-inner">
            <div class="item active"><img src="...1.jpg" alt="" /></div>
            <div class="item active"><img src="...2.jpg" alt="" /></div>
            <div class="item active"><img src="...3.jpg" alt="" /></div>
        </div>
        <a class="carousel-control left" href="#presentationCarousel" data-slide="prev">&lsaquo;</a>
        <a class="carousel-control right" href="#presentationCarousel" data-slide="next">&rsaquo;</a>
    </div>
</div>

<div id="chapterList">
    <ol class="carousel-indicators">
        <li data-target="#presentationCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#presentationCarousel" data-slide-to="1"></li>
        <li data-target="#presentationCarousel" data-slide-to="3"></li>
    </ol>
</div>

Is it possible?

Just to add, I checked out the bootstrap JS source and found this line:

this.$indicators = this.$element.find('.carousel-indicators')

It just populates the list indicators. I imagine the this reference is for the presentation div element.

JAVASCRIPT QUESTION

Is it possible to search the entire page for elements by removing the this reference?

this.$indicators = $element.find('.carousel-indicators')

Any piece of advise would be highly appreciated. Thanks!

like image 373
AnimaSola Avatar asked Mar 10 '13 02:03

AnimaSola


People also ask

How do you change the carousel indicators shape in Bootstrap 5?

You just need to override two properties ( width and height ) and add a new one, border-radius , to . carousel-indicators li . Make width and height values equal eg: 10px each and give a border-radius of 100% .

How do I display Bootstrap carousel with three posts in each slide?

Following are the steps to create a Bootstrap carousel:Apply CSS to resize the . carousel Bootstrap card body by using the code segment below. In this step, the sliding images are defined in the division tag as under. Last step is to add controls to slide images using the carousel-control class as below.

Why is Bootstrap carousel not sliding?

Carousels don't automatically normalize slide dimensions. As such, you may need to use additional utilities or custom styles to appropriately size content. While carousels support previous/next controls and indicators, they're not explicitly required. Add and customize as you see fit.


1 Answers

Bit late to the party but you could try adding a script like this...

$('#myCarousel').on('slide.bs.carousel', function () {       

$holder = $( "ol li.active" );
$holder.next( "li" ).addClass("active");  
if($holder.is(':last-child'))
{
$holder.removeClass("active");
$("ol li:first").addClass("active");
}
$holder.removeClass("active");
})   
</script>
like image 151
10chars Avatar answered Sep 25 '22 23:09

10chars