Responsive Auto-rotating Banner Carousel Plugin With jQuery - jtaCarousel

File Size: 3.04 KB
Views Total: 5773
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Responsive Auto-rotating Banner Carousel Plugin With jQuery - jtaCarousel

Yet another responsive banner carousel component that features auto rotation, pause on hover, navigation arrows and pagination bullets, built using jQuery and CSS / CSS3.

How to use it:

1. The basic HTML structure for the responsive carousel.

<div class="jtaCarousel">
  <div class="banner-controls banner-prev-position">
    <div class="banner-control-button banner-prev">
      &lt;
    </div>
  </div>
  <ul class="banner">
    <li class="banner-item">
      <div">Slide 1</div>
    </li>
    <li class="banner-item">
      <div>Slide 2</div>
    </li>
    <li class="banner-item">
      <div>Slide 3</div>
    </li>
  </ul>
  <div class="banner-controls banner-next-position">
    <div class="banner-control-button banner-next">
      &gt;
    </div>
  </div>
  <div class="banner-location"></div>
</div>

2. The primary CSS styles for the carousel:

ul.banner {
  padding-left: 0;
  margin-top: 0;
  margin-bottom: 0;
  list-style: none;
}

.jtaCarousel {
  position: relative;
  overflow: hidden;
}

.banner {  width: calc(100% * 5); }

.banner-item {
  float: left;
  width: calc(100% / 5);
}

.banner-item > div {
  /* OPTIONAL */
  background-size: cover;
  background-position: 50% 50%;
  height: 450px;
  line-height: 450px;
  font-size: 2em;
  color: #fff;
}

3. The required CSS styles for the navigation buttons and pagination bullets.

.banner-controls {
  position: absolute;
  top: 50%;
  -webkit-transform: translateY(-50%);
  transform: translateY(-50%);
}

.banner-prev-position {
  left: 0;
  padding-left: .75em;
}

.banner-next-position {
  right: 0;
  padding-right: .75em;
}

.banner-control-button {
  border-radius: 100%;
  font-size: 2em;
  color: white;
  cursor: pointer;
  -webkit-transition: opacity 100ms ease-in-out;
  transition: opacity 100ms ease-in-out;
}

.banner-control-button:hover { opacity: .5; }

.banner-location {
  position: absolute;
  z-index: 2;
  bottom: .75em;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  height: .75em;
  line-height: 1;
  cursor: default;
}

.banner-indicator {
  position: relative;
  top: 0;
  display: inline-block;
  width: .75em;
  height: .75em;
  border-radius: 100%;
  margin-left: 3px;
  background-color: rgba(255, 255, 255, 0.5);
}

.banner-indicator:first-child { margin-left: 0; }

.banner-indicator.selected {
  background-color: white;
  cursor: auto;
}

4. Place jQuery library and the jQuery jtaCarousel plugin at the end of the html page. That's it.

<script src="//code.jquery.com/jquery-3.1.1.min.js"></script> 
<script src="jtaCarousel.js"></script>

This awesome jQuery plugin is developed by jamestalmond. For more Advanced Usages, please check the demo page or visit the official website.