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://1.bp.blogspot.com/-TSQlbKMACK8/YTc6VBMF56I/AAAAAAAAA1M/IdZ3nfi4_vMOsxQIglKKc68FuU2tUfQ9QCLcBGAsYHQ/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://1.bp.blogspot.com/-qgRA1EG0G0o/YTMPa1fOnqI/AAAAAAAAAuc/dmoTneePUagJiohJXew3KqfFyWHF8SN1ACLcBGAsYHQ/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://1.bp.blogspot.com/-4rLb7-0I32w/YTMPa2LgV2I/AAAAAAAAAuY/rNo80Ys6SA01iYFJCCZrdhFhgBfCV_AQQCLcBGAsYHQ/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://1.bp.blogspot.com/-_ihL3ij5cv4/YTMPbrCsQDI/AAAAAAAAAug/HHq8Rk2F92gEk4TvNBmn4VwfPbSaX-SxACLcBGAsYHQ/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://1.bp.blogspot.com/-8wxvLVjpIXw/YTbpxKnNwEI/AAAAAAAAAvk/M2SnulZXTegMWzDN2uFzWE2jNrh0XFmsACLcBGAsYHQ/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://1.bp.blogspot.com/-VPt_W_cHsag/YTMPc-UVxVI/AAAAAAAAAuk/CibJA2oxboU-uaNYEeLPxzCUVxz-EHgMwCLcBGAsYHQ/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