Thursday, 4 August 2016

CREATE AN AUTOMATIC SLIDE SHOW HTML CSS AND JAVASCRIPT

have you ever wondered how a slide show in webpage is created relax and stay back am going to take you through the easiest way to create an automatic slide show using java-script( you dont have to be a guru to do it just open your heart)

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing:border-box}
body {font-family: Verdana,sans-serif;}

/* Slideshow container this is where your images are places  you can increase the max width if you like */


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

/* Caption text a caption is a text that appears or clearly defines what an image is saying or describing */

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

/* Number text (1/3 etc) this css styles a number text on your webpage  */

.numbertext {
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */

.dot {
  height: 13px;
  width: 13px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

/* this changes the background of the image currently being displayed */

.active {
  background-color: #717171;
}

/* Fading animation  here is where the sweet and unique effects works */

.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

@-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>


<body>
<h2>Automatic Slideshow</h2>
<p>Change image every 2 seconds:</p>

<div class="slideshow-container">

<div class="mySlides fade">
  <div class="numbertext">1 / 3</div>
  <img src="img_nature_wide.jpg" style="width:100%">
  <div class="text">Caption Text</div>
</div>

<div class="mySlides fade">
  <div class="numbertext">2 / 3</div>
  <img src="img_fjords_wide.jpg" style="width:100%">
  <div class="text">Caption Two</div>
</div>

<div class="mySlides fade">
  <div class="numbertext">3 / 3</div>
  <img src="img_mountains_wide.jpg" style="width:100%">
  <div class="text">Caption Three</div>
</div>

</div>
<br>

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

<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, 2000); // Change image every 2 seconds
}
</script>

</body>
</html>


note: for everywhere there is image your image should be there not those image name in this code else you will have a page without an image but the slider still works

here is a picture from the third slide of this code so if your code is correct you should have something like this

Automatic Slideshow

Change image every 2 seconds:
3 / 3

Caption Three

  
Share:

1 comment:

  1. Create An Automatic Slide Show Html Css And Javascript ~ Itgist >>>>> Download Now

    >>>>> Download Full

    Create An Automatic Slide Show Html Css And Javascript ~ Itgist >>>>> Download LINK

    >>>>> Download Now

    Create An Automatic Slide Show Html Css And Javascript ~ Itgist >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete