Bs Carousel

Bootstrap Carousel Plugin


The Carousel Plugin

The Carousel plugin is a constituent for cycling through elements, similar a carousel (slideshow).
Tip: Plugins tin hold upwardly included individually (using Bootstrap's private "carousel.js" file), or all at i time (using "bootstrap.js" or "bootstrap.min.js").

Carousel Example


Note: Carousels are non supported properly inward Internet Explorer ix in addition to before (because they occupation CSS3 transitions in addition to animations to accomplish the slide effect).

How To Create a Carousel

The next representative shows how to create a basic carousel:

Example

<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
    <div class="item active">
      <img src="la.jpg" alt="Los Angeles">
    </div>

    <div class="item">
      <img src="chicago.jpg" alt="Chicago">
    </div>

    <div class="item">
      <img src="ny.jpg" alt="New York">
    </div>
  </div>

  <!-- Left in addition to correct controls -->
  <a class="left carousel-control" href="#myCarousel" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

Example Explained

The outermost <div>:
Carousels require the occupation of an id (in this instance id="myCarousel") for carousel controls to component properly.
The class="carousel" specifies that this <div> contains a carousel.
The .slide bird adds a CSS transition in addition to animation effect, which makes the items slide when showing a novel item. Omit this bird if y'all exercise non desire this effect.
The data-ride="carousel" attribute tells Bootstrap to laid out animating the carousel directly when the page loads.
The "Indicators" part:
The indicators are the piffling dots at the bottom of each slide (which indicates how many slides at that topographic point is inward the carousel, in addition to which slide the user are currently viewing).
The indicators are specified inward an ordered listing amongst bird .carousel-indicators.
The data-target attribute points to the id of the carousel.
The data-slide-to attribute specifies which slide to become to, when clicking on the specific dot.
The "Wrapper for slides" part:
The slides are specified inward a <div> amongst bird .carousel-inner.
The content of each slide is defined inward a <div> amongst bird .item. This tin hold upwardly text or images.
The .active bird needs to hold upwardly added to i of the slides. Otherwise, the carousel volition non hold upwardly visible.
The "Left in addition to correct controls" part:
This code adds "left" in addition to "right" buttons that allows the user to become dorsum in addition to forth betwixt the slides manually.
The data-slide attribute accepts the keywords "prev" or "next", which alters the slide put relative to its electrical current position.

Add Captions to Slides

Add <div class="carousel-caption"> inside each <div class="item"> to create a caption for each slide:

Example

<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner">
    <div class="item active">
      <img src="la.jpg" alt="Chania">
      <div class="carousel-caption">
        <h3>Los Angeles</h3>
        <p>LA is ever in addition to thus much fun!</p>
      </div>
    </div>

    <div class="item">
      <img src="chicago.jpg" alt="Chicago">
      <div class="carousel-caption">
        <h3>Chicago</h3>
        <p>Thank you, Chicago!</p>
      </div>
    </div>

    <div class="item">
      <img src="ny.jpg" alt="New York">
      <div class="carousel-caption">
        <h3>New York</h3>
        <p>We dearest the Big Apple!</p>
      </div>
    </div>
  </div>

  <!-- Left in addition to correct controls -->
  <a class="left carousel-control" href="#myCarousel" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

Comments

Popular posts from this blog

Removing The Index.Php File From Url Inward Codeigniter

What Are The Main Components of a Computer System

Delete Daily Doppler E-Mail Spam From An Iphone [Fix]