<div class="container">
<div class="row" id="bdtContainer">
<div class="carouselContainer" id="carouselMain">
<div class="carouselInner">
<div class="imgSlide">
<img src="http://placehold.it/720x405/63393E?text=" class="img-responsive" alt="">
<a href="" class="visitBtn"><i class="fa fa-hand-o-right" aria-hidden="true"></i></a>
</div>
<div class="imgSlide">
<img src="http://placehold.it/720x405/FD5B03?text=" class="img-responsive" alt="">
<a href="" class="visitBtn"><i class="fa fa-hand-o-right" aria-hidden="true"></i></a>
</div>
<div class="imgSlide">
<img src="http://placehold.it/720x405/1DABB8?text=" class="img-responsive" alt="">
<a href="" class="visitBtn"><i class="fa fa-hand-o-right" aria-hidden="true"></i></a>
</div>
</div>
<div class="prevBtn"><i class="fa fa-caret-left" aria-hidden="true"></i></div>
<div class="nextBtn"><i class="fa fa-caret-right" aria-hidden="true"></i></div>
</div>
<div class="Left">
<div class="carouselContainerLeft">
<div class="carouselInner" id="carouselInnerLeft">
<div class="imgSlide">
<img src="http://placehold.it/720x405/1DABB8?text=" class="img-responsive" alt="">
<a href="" class="visitBtn"><i class="fa fa-hand-o-right" aria-hidden="true"></i></a>
</div>
<div class="imgSlide">
<img src="http://placehold.it/720x405/63393E?text=" class="img-responsive" alt="">
<a href="" class="visitBtn"><i class="fa fa-hand-o-right" aria-hidden="true"></i></a>
</div>
<div class="imgSlide">
<img src="http://placehold.it/720x405/FD5B03?text=" class="img-responsive" alt="">
<a href="" class="visitBtn"><i class="fa fa-hand-o-right" aria-hidden="true"></i></a>
</div>
</div>
</div>
</div>
<div class="Right">
<div class="carouselContainerRight">
<div class="carouselInner" id="carouselInnerRight">
<div class="imgSlide">
<img src="http://placehold.it/720x405/FD5B03?text=" class="img-responsive" alt="">
<a href="" class="visitBtn"><i class="fa fa-hand-o-right" aria-hidden="true"></i></a>
</div>
<div class="imgSlide">
<img src="http://placehold.it/720x405/1DABB8?text=" class="img-responsive" alt="">
<a href="" class="visitBtn"><i class="fa fa-hand-o-right" aria-hidden="true"></i></a>
</div>
<div class="imgSlide">
<img src="http://placehold.it/720x405/63393E?text=" class="img-responsive" alt="">
<a href="" class="visitBtn"><i class="fa fa-hand-o-right" aria-hidden="true"></i></a>
</div>
</div>
</div>
</div>
</div>
</div>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
#bdtContainer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
position: relative;
}
#carouselMain {
-webkit-box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.25);
-moz-box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.25);
box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.25);
}
.carouselContainer {
width: 720px;
height: 405px;
overflow: hidden;
position: relative;
.carouselInner {
display: flex;
position: absolute;
transition: left ease-out 0.3s;
.imgSlide {
width: 720px;
height: 405px;
position: relative;
.visitBtn {
position: absolute;
bottom: 40px;
right: 40px;
width: 30px;
height: 30px;
color: #f4f4f4;
line-height: 30px;
border: 1px solid #f4f4f4;
text-align: center;
opacity: 0;
transition: all ease-in-out 0.3s;
}
}
&:hover .visitBtn {
opacity: 0.5;
}
}
.prevBtn,
.nextBtn {
position: absolute;
top: 50%;
right: 0;
font-size: 2em;
width: 40px;
height: 40px;
color: #f4f4f4;
text-align: center;
line-height: 40px;
cursor: pointer;
opacity: 0;
transform: translateY(-50%);
transition: all ease-in-out 0.3s;
}
.prevBtn {
left: 0;
}
&:hover .nextBtn,
&:hover .prevBtn {
opacity: 0.5;
}
}
.Left {
position: absolute;
left: 0;
z-index: -10;
}
.carouselContainerLeft {
width: 640px;
height: 360px;
overflow: hidden;
position: relative;
.carouselInner {
display: flex;
position: absolute;
transition: left ease-out 0.3s;
.imgSlide {
width: 640px;
height: 360px;
position: relative;
.visitBtn {
position: absolute;
bottom: 40px;
right: 40px;
width: 30px;
height: 30px;
color: #f4f4f4;
line-height: 30px;
border: 1px solid #f4f4f4;
text-align: center;
opacity: 0;
transition: all ease-in-out 0.3s;
}
}
&:hover .visitBtn {
opacity: 0.5;
}
}
.prevBtn,
.nextBtn {
position: absolute;
top: 50%;
right: 0;
font-size: 2em;
width: 40px;
height: 40px;
color: #f4f4f4;
text-align: center;
line-height: 40px;
cursor: pointer;
opacity: 0;
transform: translateY(-50%);
transition: all ease-in-out 0.3s;
}
.prevBtn {
left: 0;
}
&:hover .nextBtn,
&:hover .prevBtn {
opacity: 0.5;
}
}
.Right {
position: absolute;
right: 0;
z-index: -20;
}
.carouselContainerRight {
width: 640px;
height: 360px;
overflow: hidden;
position: relative;
.carouselInner {
display: flex;
position: absolute;
transition: left ease-out 0.3s;
.imgSlide {
width: 640px;
height: 360px;
position: relative;
.visitBtn {
position: absolute;
bottom: 40px;
right: 40px;
width: 30px;
height: 30px;
color: #f4f4f4;
line-height: 30px;
border: 1px solid #f4f4f4;
text-align: center;
opacity: 0;
transition: all ease-in-out 0.3s;
}
}
&:hover .visitBtn {
opacity: 0.5;
}
}
.prevBtn,
.nextBtn {
position: absolute;
top: 50%;
right: 0;
font-size: 2em;
width: 40px;
height: 40px;
color: #f4f4f4;
text-align: center;
line-height: 40px;
cursor: pointer;
opacity: 0;
transform: translateY(-50%);
transition: all ease-in-out 0.3s;
}
.prevBtn {
left: 0;
}
&:hover .nextBtn,
&:hover .prevBtn {
opacity: 0.5;
}
}
View Compiled
var carousel = document.getElementsByClassName('carouselContainer');
[].forEach.call(carousel, function(c) {
console.log(c);
let prev = c.getElementsByClassName('prevBtn')[0],
next = c.getElementsByClassName('nextBtn')[0],
inner = c.getElementsByClassName('carouselInner')[0],
innerLeft = document.getElementById('carouselInnerLeft'),
slidesLeft = innerLeft.getElementsByClassName('imgSlide'),
innerRight = document.getElementById('carouselInnerRight'),
slidesRight = innerRight.getElementsByClassName('imgSlide'),
slides = inner.getElementsByClassName('imgSlide'),
width = 720, slideIndex = 0, widthSmall = 640;
function slideShow() {
inner.style.left = -width * slideIndex + 'px';
innerLeft.style.left = -widthSmall * slideIndex + 'px';
innerRight.style.left = -widthSmall * slideIndex + 'px';
}
prev.addEventListener('click', function () {
slideIndex--;
if (slideIndex < 0) {
slideIndex = slides.length - 1;
}
slideShow();
});
next.addEventListener('click', function () {
slideIndex++;
if (slideIndex >= slides.length) {
slideIndex = 0;
}
slideShow();
});
});
This Pen doesn't use any external JavaScript resources.