I have a carousel for a product and it has 1 image and 1 video. The image shows up alright but when I try to press on the video so it pops up into main carousel view, it doesn’t work. My index.html code (I omitted the actual video link from this source code) is:
<div id="content-wrapper">
<div class="column">
<img id=featured src="images/sample1.jpg">
<div id="slide-wrapper" >
<div id="slider">
<img class="thumbnail active" src="images/sample1.jpg">
<iframe class="thumbnail" width="560" height="315" src="videolink" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div>
</div>
</div>
<div class="col-2">
<p>Home / Sample Item 1</p>
<h1>Sample Item 1</h1>
<h4>$00.00</h4>
<h3>Product Details</h3><br>
<p>Manufactured in CANADA</p>
</div>
</div>
In the same source code I have a Javascript code:
<script type="text/javascript">
let thumbnails = document.getElementsByClassName('thumbnail')
let activeImages = document.getElementsByClassName('active')
for (var i=0; i < thumbnails.length; i++){
thumbnails[i].addEventListener('mouseover', function(){
console.log(activeImages)
if (activeImages.length > 0){
activeImages[0].classList.remove('active')
}
this.classList.add('active')
document.getElementById('featured').src = this.src
})
}
let buttonRight = document.getElementById('slideRight');
let buttonLeft = document.getElementById('slideLeft');
buttonLeft.addEventListener('click', function(){
document.getElementById('slider').scrollLeft -= 180
})
buttonRight.addEventListener('click', function(){
document.getElementById('slider').scrollLeft += 180
})
</script>
My CSS code:
body{
padding-top: 100px;
}
#content-wrapper{
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
.column{
width: 600px;
padding: 10px;
}
#featured{
max-width: 500px;
max-height: 600px;
object-fit: cover;
cursor: pointer;
border: 2px solid black;
}
.thumbnail{
object-fit: cover;
max-width: 180px;
max-height: 100px;
cursor: pointer;
opacity: 0.5;
margin: 5px;
border: 2px solid black;
}
.thumbnail:hover{
opacity:1;
}
.active{
opacity: 1;
}
#slide-wrapper{
max-width: 500px;
display: flex;
min-height: 100px;
align-items: center;
}
#slider{
width: 440px;
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
}
#slider::-webkit-scrollbar {
width: 8px;
}
#slider::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
#slider::-webkit-scrollbar-thumb {
background-color: #dede2e;
outline: 1px solid slategrey;
border-radius: 100px;
}
#slider::-webkit-scrollbar-thumb:hover{
background-color: #18b5ce;
}
.arrow{
width: 30px;
height: 30px;
cursor: pointer;
transition: .3s;
}
.arrow:hover{
opacity: .5;
width: 35px;
height: 35px;
}
When I hover over the image – the image works and I can see it, but when I hover over the little embedded video, it gives a broken image sign in the main carousel view (above the thumbnail). What am I doing wrong? How can I make the video show up normally when I hover over it?