This is what I have so far. I'm able to keep the images in container but the arrows aren't working.
I need help with the Jquery part and making the images run cycle by themselves but also allow arrows to be clicked to change the images.
/*HEADER SECTION allwork*/ #container { width: 1200px; height: 628px; border: 0px solid black; margin: 0 auto; position: relative; } #container>img { width: 100% height: 100%; position: absolute; #container>.btn1 { position: absolute; width: 50px; height: 50px; border: none; border-radius: 15px; top: 150px; background: #2ecc71; color: white; font-size: 30px; } #container>#btn1:hover { box-shadow: 10px 0px 20px 0px #2ecc71; } #container>#btn1:hover { box-shadow: 10px 0px 20px 0px #2ecc71; } #container>#btn1 { position: relative; float: right; }
<!DOCTYPE html> <html lang="en"> <head> <meta name 'viewport' content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="HandheldFriendly" content="true"> <meta Charset='uft-8'> <link rel='shortcut icon' href="images/favicon.png"> <link rel="stylesheet" href="index.css"> </head> <body> <div id="head"> <div class="header"> <img class="logo" src="images/LOGO.png" alt="logo" /> <ul> <li><a class="navbar" href="index.hmtl">About</a></li> <li><a class="navbar" href="resume.hmtl">Resume</a></li> <li><a class="navbar" href="all work.hmtl">All Work</a></li> </ul> </div> </div> <div id="container"> <img class="slides" src="images/overview.png"> <img class="slides" src="images/construction.png"> <button class="btn1" onclick="plusDivs(-1)">❮</button> <button class="btn2" onclick="plusDivs(+1)">❯</button> </div> <script src="jquery.js"></script> <script src="script.js"></script> </body> </html>
I would suggest you to go through the link
https://www.w3schools.com/howto/howto_js_slideshow.asp
The slideshow is ideally known as Carousel. You can also look into bootstrap framework which has in built carousel support
https://www.w3schools.com/bootstrap/bootstrap_carousel.asp
Here is the javascript code :
<script>
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("slides");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
x[slideIndex-1].style.display = "block";
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.