Pagina 1 din 1

Problema slideshow imagini

Scris: Joi Dec 28, 2017
de elena
buna,
am acest cod cu ajutorul caruia pot rula mai multe imaigini de tip slideshow, dar se opreste la imaginea nr patru si nu stiu care e problema.

Cod: Selectaţi tot

<!DOCTYPE html>
<html>
<head>

<style>
body {
background: black;
margin:0 auto;
}
.continut{
margin:10px;
padding:20px;
width:1400px;
height:700px;
border:2px solid black;
background-image: url("gradient.png");

}
.slideshow-container {
max-width: 700px;
position: relative;
margin: auto;
padding:20px;

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

}

.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;
}

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

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

@keyframes fade {
from {opacity: .2} 
to {opacity: 2}
}


</style>
</head>
<body>
<div class="continut">

<div class="slideshow-container">

<div class="mySlides fade">
<div class="numbertext">1 / 6</div>
<img src="unu.jpg" style="width:100%">
</div>

<div class="mySlides fade">
<div class="numbertext">2 / 6</div>
<img src="doi.jpg" style="width:100%">
</div>

<div class="mySlides fade">
<div class="numbertext">3 / 6</div>
<img src="trei.jpg" style="width:100%">
</div>

<div class="mySlides fade">
<div class="numbertext">4 / 6</div>
<img src="patru.jpg" style="width:100%">
</div>

<div class="mySlides fade">
<div class="numbertext">5 / 6</div>
<img src="unu.jpg" style="width:100%">
</div>

<div class="mySlides fade">
<div class="numbertext">6 / 6</div>
<img src="sase.jpg" style="width:100%">
</div>

</div>
<br>

<div style="text-align:center">
<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>
</div>
<script>
var slideIndex = 0;
showSlides();

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

</body>
</html>

Problema slideshow imagini

Scris: Joi Dec 28, 2017
de MarPlo
Salut
Incearca sa inlocuiesti script-ul JS din codul tau cu acesta:

Cod: Selectaţi tot

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

function showSlides() {
  var i;
  var slides = document.getElementsByClassName("mySlides fade");
  var dots = document.getElementsByClassName("dot");
  for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none"; 
  }
  if (slideIndex > slides.length) slideIndex = 1;
  for (i = 0; i < dots.length; i++) {
    dots[i].className = dots[i].className.replace(" active", "block");
  }

  slides[slideIndex-1].style.display = "block"; 
  if(dots[0]) dots[0].className = " active";
  slideIndex++;
  setTimeout(showSlides, 2000); 
}
</script>
- Poti sa incerci si script-urile de SlideShow de la aceste pagini:
https://coursesweb.net/javascript/slides ... ascript_s2
https://coursesweb.net/jquery/feature-ca ... ideshow_jp

Problema slideshow imagini

Scris: Vin Dec 29, 2017
de elena
am inlocuit:

Cod: Selectaţi tot

if(dots[0]) dots[0].className = " active";
cu acesta:

Cod: Selectaţi tot

if(dots[0]) dots[1].className = " active";
si a functionat.
Multumesc!