🐸 html
<div class="slideshow-container">
<div class="mySlides fade">
<img src="image01.jpg" alt="Little by little does the trick" style="width:100%; height:265px;" />
<div class="text">Little by little does the trick</div>
</div>
<div class="mySlides fade">
<img src="image02.jpg" alt="You will never know until you try" style="width:100%; height:265px;" />
<div class="text">You will never know until you try</div>
</div>
<div class="mySlides fade">
<img src="image03.jpg" alt="Whatever you do, make it pay" style="width:100%; height:265px;" />
<div class="text">Whatever you do, make it pay</div>
</div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
<br>
<div style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
🐸 css
.mySlides {
width:100%;
height:250px;
}
img {
vertical-align: middle;
}
.slideshow-container {
max-width: 100%;
position: relative;
margin: auto;
}
.prev, .next {
position: absolute;
top: 45%;
width: auto;
padding: 16px;
margin-top: -22px;
color: white;
font-weight: bold;
font-size: 50px;
transition: 0.6s ease;
border-radius: 0 3px 0;
cursor: pointer;
}
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}
.text {
color: #f2f2f2;
font-size: 35px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
.dot {
cursor: pointer;
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: #725275 0.6s ease;
}
.active, .dot:hover {
background-color: #725275;
}
.fade {
animation-name: fade;
animation-duration: 1.5s;
}
@keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
@media only screen and (max-width: 300px) {
.prev, .next,.text {font-size: 11px}
}
🐸 javascript
let slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
let i;
let slides = document.getElementsByClassName("mySlides");
let dots = document.getElementsByClassName("dot");
let prev = document.getElementsByClassName('prev');
let next = document.getElementsByClassName('next');
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";
setTimeout(showSlides, 2000);
}