Minimal jQuery Image Carousel Slider Plugin - Dynamic Slider

File Size: 1.98 MB
Views Total: 1236
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Minimal jQuery Image Carousel Slider Plugin - Dynamic Slider

Dynamic Slider is a basic jQuery & CSS3 based carousel slider that images are added and removed from the DOM dynamically through JavaScript. There will only be 3 active images within the DOM after each rotation.

How to use it:

1. Include the needed jQuery library in the web page.

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

2. Build the Html structure for an image carousel with next/prev controls.

<div id="slider">
  <div id="buttons">
    <div id="leftArrow" class="arrows"></div>
    <div id="rightArrow" class="arrows"></div>
  </div>
  <div id="slideContainer">
    <div id="slides"></div>
    <div id="captions">
      <p id="captionTxt">This is picture number <span id="imgNumberTxt">1</span></p>
    </div>
  </div>
</div>

3. Add the following CSS/CSS3 styles into your CSS file to style the image carousel. Free feel to tweak or override them to create your own styles.

#slider {
  width: 800px;
  height: 500px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  padding: 5px;
  background: #fff;
  border: 1px solid #333;
  box-shadow: 0 0 10px 5px rgba(0,0,0,0.5);
}

.no-boxshadow #slider { border: 4px outset #555; }

#slideContainer {
  overflow: hidden;
  width: 800px;
  height: 500px;
  position: relative;
  top: 0;
  left: 0;
}

#slides {
  position: relative;
  top: 0;
  left: -800px;
  width: 2400px;
  height: 100%;
}

#slides > *.sliderImg {
  float: left;
  width: 800px;
  height: 500px;
}

#buttons {
  position: relative;
  z-index: 10;
}

.arrows {
  position: absolute;
  top: 200px;
  height: 100px;
  width: 50px;
  cursor: pointer;
  opacity: 0.6;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=60)"; /* IE 8 */
  filter: alpha(opacity=60); /* IE 7 */
  transition: opacity 0.2s ease-in;
  -webkit-transition: opacity 0.2s ease-in;
  -moz-transition: opacity 0.2s ease-in;
  -o-transition: opacity 0.2s ease-in;
  -ms-transition: opacity 0.2s ease-in;
}

.arrows.over {
  opacity: 1;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; /* IE 8 */
  filter: alpha(opacity=100); /* IE 7 */
}

#rightArrow {
  background: url('right_arrow.png') no-repeat 0 0;
  right: 0;
  margin-right: -5px;
}

#rightArrow.down { margin-right: -7px; }

#leftArrow {
  background: url('left_arrow.png') no-repeat 0 0;
  left: 0;
  margin-left: -5px;
}

#leftArrow.down { margin-left: -7px; }

#captions {
  width: 295px;
  height: 98px;
  background: url('caption_bg.png') no-repeat 0 0;
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 10;
}

#captionTxt {
  color: #129adc;
  font-weight: normal;
  font-size: 22px;
  position: absolute;
  left: 30px;
  top: 38px;
}

4. Include the functions.js after jQuery library to enable the image carousel. Replace the default images with your owns using imgDir and images objects.

<script src="js/functions.js"></script>

Change logs:

2014-11-13

2014-10-25

  • Minor updates.
  • Dropped IE8 support

2014-10-24

  • Minor updates.

2014-10-23

  • added retina support.

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