Currently, I am in the process of creating a visually appealing image "slider" for a landing page on one of my websites. The slider that I have already created is fully functional and successful, but I am looking to take it up a notch...
My goal is to incorporate a feature that enables crossfading images upon selection (when a tile is clicked below the main image area), similar to what is explained on this website here (under Demo 6 - Fading between multiple images on click).
I attempted to integrate the code from this site into the existing JS code that I have added within the HTML file. Unfortunately, it seems to be causing conflicts with the current elements. You can find the JSFiddle for the current code here.
@charset "utf-8";
/* CSS Document */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
.main-slide {
height: 250px;
width: 750px;
margin: auto;
}
.selection-panel {
opacity: 0.6;
filter: alpha(opacity=60);
}
.selection-panel:hover {
opacity:1.0;
filter: alpha(opacity=100);
}
.selection-panel-off {
opacity: 1.0;
filter: alpha(opacity=100);
}
.margins {
margin-top: 16px!important;
margin-bottom: 16px!important;
}
.image-spacing,.image-spacing>.single-col {
padding: 0 8px;
}
.single-col {
float: left;
width: 100%;
}
.single-col.third {
width: 33.33333%;
}
.image-spacing::after,.image-spacing::before {
content: "";
display: table;
clear: both;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Homepage Baner Module</title>
<link rel="stylesheet" href="formatting.css" type="text/css" media="screen">
<style>
.mySlides {display:none}
.demo {cursor:pointer}
</style>
</head>
<body>
<div class="main-image" style="max-width:750px">
<img class="mySlides" src="https://dummyimage.com/750x250/ff5100/fff" height="250px" width="100%">
<img class="mySlides" src="https://dummyimage.com/750x250/00ff51/fff" height="250px" width="100%">
<img class="mySlides" src="https://dummyimage.com/750x250/0055ff/fff" height="250px" width="100%">
<div class="margins image-spacing">
<div class="single-col third">
<img class="demo selection-panel" src="https://dummyimage.com/750x250/ff5100/fff" style="width:100%" onclick="currentDiv(1)">
</div>
<div class="single-col third">
<img class="demo selection-panel" src="https://dummyimage.com/750x250/00ff51/fff" style="width:100%" onclick="currentDiv(2)">
</div>
<div class="single-col third">
<img class="demo selection-panel" src="https://dummyimage.com/750x250/0055ff/fff" style="width:100%" onclick="currentDiv(3)">
</div>
</div>
</div>
<script>
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function currentDiv(n) {
showDivs(slideIndex = n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("demo");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" selection-panel-off", "");
}
x[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " selection-panel-off";
}
</script>
</body>
</html>