image slider CSS || Simple JAVA image slider || image slider for web-design

IMAGE SLIDER CSS


 Image slider adds extra enhancement to site. Its a better way to show the product or feature in slideshow. With combination of CSS and JAVA we have created a simple slideshow code. Its useful in all CMS like WordPress, BlogSpot etc.

    If you need more layer of image just do the following
  •  Copy and paste a <div class="mySlides fade"> DIV
  • Add <span class="dot"></span>  another span in DIV <div style="text-align:center; display:none">


You can use your style as per your design


HTML CODE ::

<div class="slideshow-container" style="margin-top:10px;">

<div class="mySlides fade">
  <div class="numbertext"></div>
  <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzG3wgBE4-vOq10oM7ihOIKkbM89GuSu8L0Brmxj4s_7yOyhoUAntEz-UAM_FsJ_QPmz5Tlle045tzNbELkVvkuy6ckdERyJnm395OSvk966tlQQQOVAMjLMmJnGSygd1BasD0DFmt9d8/s16000/ca-2.jpg" draggable="false" role="img" 
 style="width:100%" />
  <div class="text"></div>
</div>

<div class="mySlides fade">
  <div class="numbertext"></div>
  <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIt7GpyoRj8iJevecQCKPZflaWItBrBa2A3ughHq-leixVKNN_x4eo77UrJ74VpgbG56CMeA-XZvOPnifLsyzhWo6c4w-C4FIXJNj-1VWdtYq3usMpReyWJnmJT8nwfAfHuCZHk4yURuw/s16000/ca-3.jpg" draggable="false" role="img"  style="width:100%" />
  <div class="text"></div>
</div>

<div class="mySlides fade">
  <div class="numbertext"></div>
  <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9nbYDD8LuY3HFKnvhCgeWRU_TWs-zk4a6FxLyNUmoc4ezbYK_b5mIHuy3DQH_Gxxv_uxf1iiO_w0RksCAm-HTrQmUx3d0FzBxMJkxO-7SfwWz9at_b7-w6lWJLv7ZigYwgsCvTiYGMHs/s16000/ca-4.jpg" draggable="false" role="img"  style="width:100%" />
  <div class="text"></div>
</div>

<div class="mySlides fade">
  <div class="numbertext"></div>
  <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpjt8lg6K7vVJw1DAbpEJPWD99iUg4LfzFEo3gWkURDzU2IJQxhSPb6XRyAz_4Kq_VZHvKP4XDKExrRL4yolF67erHfWhMtSzXTdQSk7ytcaDKtu3rZKGPWLGO2KQ-Zb57Cxyhn_jQUs4/s16000/ca-5.jpg" draggable="false" role="img"  style="width:100%" />
  <div class="text"></div>
</div>

<div class="mySlides fade">
  <div class="numbertext"></div>
  <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSFOqzmAJI_EYY9w3Q6AjjBVqNkZ3u_b7ipLyXvNMVdQ1ekGtRM1-wOEPKBVN62E1OqyB3Ebcm0WR2TkXrneNuO7jT58nnAnrYh5oq3dIMQU7Bq0DtA6FOD7o0BcDJAnGD13wszz2Pq98/s16000/ca-6.jpg" draggable="false" role="img" 
 style="width:100%" />
  <div class="text"></div>
</div>

<div class="mySlides fade">
  <div class="numbertext"></div>
  <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii1Muif3uCH5DG9WKN1xDr6J4OpMXS6PwviXhBOp1wI-7T-zGfILJnhkO0T1qVgC2U1x1s_A0K8IhijGrtSfQmBklcrfgDnHwRvHJwrI_LQyhYyay1XKiQ0xoKZC8KPa07ec1-_uiXJlA/s16000/ca-7.jpg" draggable="false" role="img"  style="width:100%" />
  <div class="text"></div>
</div>

</div>

<div style="text-align:center; display:none">
  <span class="dot"></span> 
  <span class="dot"></span> 
  <span class="dot"></span> 
  <span class="dot"></span> 
  <span class="dot"></span> 
  <span class="dot"></span> 
</div>


JAVA CODE ::

<script>
var slideIndex = 0;
showSlides();

function showSlides() {
  var i;
  var slides = document.getElementsByClassName("mySlides");
  var dots = document.getElementsByClassName("dot");
  for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";  
  }
  slideIndex++;
  if (slideIndex > slides.length) {slideIndex = 1}    
  for (i = 0; i < dots.length; i++) {
    dots[i].className = dots[i].className.replace(" active", "");
  }
  slides[slideIndex-1].style.display = "block";  
  dots[slideIndex-1].className += " active";
  setTimeout(showSlides, 9000); // Change image every 2 seconds
}
</script>


STYLE CSS ::


<style>

/* Slideshow container */
.slideshow-container {
  max-width: 1000px;
  position: relative;
  margin: auto;
}

/* Caption text */
.text {
  color: #f2f2f2;
  font-size: 15px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}

/* Number text (1/3 etc) */
.numbertext {
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */
.dot {
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active {
  background-color: #717171;
}

/* Fading animation */
.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 9.11s;
  animation-name: fade;
  animation-duration: 3.1s;
&:hover {
    animation-play-state: paused !important;
  }

}
 
@-webkit-keyframes fade {
  from {opacity: .4} 
  to {opacity: 1}
}

@keyframes fade {
  from {opacity: .4} 
  to {opacity: 1}
}

/* On smaller screens, decrease text size */
@media only screen and (max-width: 300px) {
  .text {font-size: 11px}
}
</style>




SEE THE DEMO




Previous Post Next Post