Bootstrap 2.3ish Carousel

A demo of a Twitter Bootstrap Carousel with pills - a feature expected for v2.3. For SO http://stackoverflow.com/q/12046890/570918

by mmfansler

HTML

<script src="https://github.com/mikaelbr/bootstrap/raw/ff0b9ef165e830b34c52f9bb029ff407b892cf2d/js/bootstrap-carousel.js"></script>
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/js/bootstrap-transition.js"></script>
<script src="http://lesscss.googlecode.com/files/less-1.3.0.min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.0.4/css/bootstrap-combined.min.css">
<div id="myCarousel" class="carousel slide">
  <!-- Carousel items -->
  <div class="carousel-inner">
    <div class="active item">
        <img src="//placehold.it/400x200"></div>
    <div class="item"><img src="//placehold.it/400x200"></div>
    <div class="item"><img src="//placehold.it/400x200"></div>
  </div>
</div>

CSS

// Grays
// -------------------------
@black:                 #000;
@grayDarker:            #222;
@grayDark:              #333;
@gray:                  #555;
@grayLight:             #999;
@grayLighter:           #eee;
@white:                 #fff;

// Drop shadows
.box-shadow(@shadow) {
  -webkit-box-shadow: @shadow;
     -moz-box-shadow: @shadow;
          box-shadow: @shadow;
}

// Border Radius
.border-radius(@radius) {
  -webkit-border-radius: @radius;
     -moz-border-radius: @radius;
          border-radius: @radius;
}

// Gradients
#gradient {
  .vertical(@startColor: #555, @endColor: #333) {
    background-color: mix(@startColor, @endColor, 60%);
    background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+
    background-image: -ms-linear-gradient(top, @startColor, @endColor); // IE10
    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
    background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+
    background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10
    background-image: linear-gradient(top, @startColor, @endColor); // The standard
    background-repeat: repeat-x;
    filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@startColor,@endColor)); // IE9 and down
  }
}

// Pills for indicating active image
// ---------------------------------

.carousel-pills {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 10px;
  display: block;
  text-align: right;
}

.carousel-pills span {
  display: inline-block;
  margin: 0px 5px;
  width: 10px;
  height: 10px;
  .border-radius(15px);
  background: @grayDark;
  @shadow: 0 1px 3px rgba(0,0,0,.25), inset 0 -1px 0 rgba(0,0,0,.1);
  .box-shadow(@shadow);
  cursor: pointer;

  &.active-pill {
    #gradient > .vertical(@white, @grayLighter);
  }

  &:hover {
    background: @grayLighter;
 ...

JavaScript

/* Add LESS support to the browser */
(function(){ $('head style[type="text/css"]').attr('type', 'text/less');less.refreshStyles(); })();
    
$('#myCarousel').carousel();