Created
April 28, 2020 16:34
-
-
Save revitalk/ce7ed45d9f380073375bf6e914325737 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container{ | |
max-width:1140px; | |
margin-left:auto; | |
margin-right:auto; | |
} | |
.slideshow{ | |
position: relative; | |
display:flex; | |
flex-direction: column; | |
justify-content: center; | |
} | |
#mypic{ | |
width:100%; | |
} | |
.slide-back{ | |
position:absolute; | |
left:8px; | |
} | |
.slide-next{ | |
position: absolute; | |
right:8px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Slideshow</title> | |
<script type="text/javascript" src="gallery.js"></script> | |
<link rel="stylesheet" href="gallery.css"> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="slideshow"> | |
<a href="#" class="slide-back" onclick="slideshowBack(); return false;"> | |
<img src="images/back.png" alt="back"> | |
</a> | |
<!-- Place the first image here --> | |
<img src="images/slide1.jpg" alt="" id="mypic"> | |
<a href="#" class="slide-next" onclick="slideshowUp(); return false;"> | |
<img src="images/next.png" alt="next"></a> | |
</div> <!-- #slide --> | |
</div> <!-- #container --> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var num = 0; | |
//Replace with your own values and add additional lines for more images | |
imgArray = [ | |
['images/slide1.jpg'], | |
['images/slide2.jpg'], | |
['images/slide3.jpg'], | |
['images/slide4.jpg'] | |
] | |
//Function called by clicking on 'next' link | |
//Replace id name with the id name you gave to the img | |
function slideshowUp() { | |
num++; | |
num = num % imgArray.length; | |
document.getElementById('mypic').src=imgArray[num]; | |
} | |
//Function called by clicking on 'previous' link | |
function slideshowBack() { | |
num--; | |
if (num < 0) {num=imgArray.length-1;} | |
num = num % imgArray.length; | |
document.getElementById('mypic').src=imgArray[num]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment