Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Carousel Slide Doesn't Work

I'm trying to implement Twitter Bootstrap Carousel plug in. It looks and auto cycles correctly, but the slide effect between items does not work. It simply statically replaces one item with the next. While it's functional, this is a less than pleasing UX. Thoughts?

<div class="span7">
        <div id="myCarousel" class="carousel slide">
          <div class="carousel-inner">
            <div class="item active">
              <img src="img/CoachellaValley.png" alt="">
              <div class="carousel-caption">
                <h4>Sponsor 1</h4>
              </div>
            </div>
            <div class="item">
              <img src="img/CoachellaValley2.png" alt="">
              <div class="carousel-caption">
                <h4>Sponsor 2</h4>
              </div>
            </div>
            <div class="item">
              <img src="img/CoachellaValley3.png" alt="">
              <div class="carousel-caption">
                <h4>Sponsor 3</h4>
              </div>
            </div>
          </div>
          <a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>
          <a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>
        </div>
      </div>
[...]
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/bootstrap-collapse.js"></script>
<script src="js/bootstrap-carousel.js"></script>
<script type="text/javascript">
  $(function(){
    $('#myCarousel').carousel();
  })
  </script>
like image 969
d_meyer Avatar asked Apr 03 '12 00:04

d_meyer


People also ask

Why is Bootstrap carousel not sliding?

In browsers where the Page Visibility API is supported, the carousel will avoid sliding when the webpage is not visible to the user (such as when the browser tab is inactive, the browser window is minimized, etc.).

Why is carousel not loading images?

To correct this, first make sure that all of your carousel images are exactly the same size in both height and width. The Homepage Carousel requires that all of the images be physically sized exactly the same as one another in order to provide a seamless transition between each.

How do I Autoplay Bootstrap carousel?

To set or to stop autoplay in Bootstrap carousel you can use data attributes or JavaScript code. You'll find detailed documentation and code examples of Bootstrap Carousel in Bootstrap Carousel Docs. Note: Autoplay for the carousel is turned on from default.

Does Bootstrap carousel need JavaScript?

Bootstrap takes advantage of the CSS transform property and some JavaScript to operate the carousel as it moves from one slide to the next.


1 Answers

Try this:

Remove all the following js scripts you have loaded in your document:

<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-collapse.js"></script>
<script src="js/bootstrap-carousel.js"></script>

And just keep the following in that same order (jQuery goes first)

<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/bootstrap.js"></script>

The problem i believe is that, aside from loading the same script files multiple times (the bootstrap js file has all the plugins included already so no need to include the min version (save it for production for now) or the single separate script files), you're not loading the transition script included inside the bootstrap.js file because of the order that your scripts are loading in.

like image 117
Andres Ilich Avatar answered Nov 01 '22 17:11

Andres Ilich