In my WordPress based on Bootstrap v.4.3 framework, I have an image based carousal and a solid-color layer div on top of it.
I want the solid-color layer to fade-out and reveal the beneath carousal image for each carousel-item, example in this theme (https://themes.muffingroup.com/be/architect5/?utm_source=demos).
Below the HTML:
<div class="container-fluid home-slide no-gutters" id="home-slide">
<!-- IMAGES ROW -->
<div class="row slide-images-row">
<div id="carousel-home" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="/img/one.png" class="img-responsive d-block"/>
</div>
<div class="carousel-item">
<img src="/img/two.png" class="img-responsive d-block"/>
</div>
</div>
</div>
</div>
<!-- SOLID LAYER ROW -->
<div class="row slide-layer-row">
<div class="slide-layer"></div>
</div>
</div>
Below the CSS for positioning the .slide-layer-row row div, which is solid-color layer on top of carousal:
.home-slide {
position: relative;
}
.slide-layer-row {
background-color: #ccc;
position: absolute;
z-index: 10;
top: 0;
left: 0;
margin: 0;
bottom: 0;
right: 0;
}
I have aligned the .slide-layer to animate the fadeout using jQuery on the carousal events with below code:
$('#carousel-home').on('slide.bs.carousel', function () {
$(".slide-layer").css('background-color', '#ccc');
$(".slide-layer").hide("slide", { direction: "left" }, 1000);
});
$('#carousel-home').on('slid.bs.carousel', function () {
$(".slide-layer").css('background-color', 'rgba(0,0,0,0.5)');
});
The slide-to-left and fadeOut is not happening.
Here is the JSFiddle (https://jsfiddle.net/kingBethal/s1g56bf0/8/).
Help me out.
In my case i am using bootstrap carousels
activeclass andpseudoelement to to give the greybackground