Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Hie guys I'm struggling to put a slideshow on my webpage. Please help

<!-- Slideshow container --> <div class="mySlides fade"> <div class="numbertext">1 / 8</div> <img src="Images/fst-picture.jpg" style="width:80%"> <div class="text">Splash paint T-shirt</div> </div>

    <div class="mySlides fade">
      <div class="numbertext">2 / 8</div>
      <img src="Images/jacket.jpg" style="width:80%">
      <div class="text">Customised Jacket</div>
    </div>

    <div class="mySlides fade">
      <div class="numbertext">3 / 8</div>
      <img src="Images/arto.jpg" style="width:80%">
      <div class="text">Splash paint Jeans</div>
    </div>

    <div class="mySlides fade">
      <div class="numbertext">4 / 8</div>
      <img src="Images/jeans.jpg" style="width:80%">
      <div class="text">Customised Jeans</div>
    </div>

    <div class="mySlides fade">
      <div class="numbertext">5 / 8</div>
      <img src="Images/second.jpg" style="width:80%">
      <div class="text">Customised Shoes</div>
    </div>

    <div class="mySlides fade">
      <div class="numbertext">6 / 8</div>
      <img src="Images/jeansj.jpg" style="width:80%">
      <div class="text">Customised Jeans</div>
    </div>

    <div class="mySlides fade">
      <div class="numbertext">7 / 8</div>
      <img src="Images/customjac.jpg" style="width:80%">
      <div class="text">Customised Jacket</div>
    </div>

    <div class="mySlides fade">
      <div class="numbertext">8 / 8</div>
      <img src="Images/bfjeans.jpg" style="width:80%">
      <div class="text">Customised Boyfriend Jeans</div>
    </div>

    <!-- Next and previous buttons -->
    <a class="prev" onclick="plusSlides(-1)">&#10094;</a>
     <a class="next" onclick="plusSlides(1)">&#10095;</a>
</div>
    <br>

CSS

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

/Next and previous buttons/ .prev, .next { cursor: pointer; position: absolute; top: 50%; width: auto; margin-top: -22px; padding: 16px; color: white; font-weight: bold; font-size: 18px; transition: 0.6s ease; border-radius: 0 3px 3px 0; }

/* Position the "next button" to the right */ .next { right: 0; border-radius: 3px 0 0 3px; }

/* On hover, add a black background color with a little bit see-through */ .prev:hover, .next:hover { background-color: rgba(0,0,0,0.8); }

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

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

.active, .dot:hover { background-color: #717171; }

/* Fading animation */ .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} }

JavaScript

var slideIndex = 1; showSlides(slideIndex);

// Next/previous controls function plusSlides(n) { showSlides(slideIndex += n); }

// Thumbnail image controls function currentSlide(n) { showSlides(slideIndex = n); }

function showSlides(n) { var i; var slides = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("dot"); if (n > slides.length) {slideIndex = 1} if (n < 1) {slideIndex = slides.length} for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } 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"; }