Answer the question
In order to leave comments, you need to log in
How to set opacity to the last slider block?
The slick slider has a slick-current class, you can set it to opacity 0.3 and thus every first visible slider block will become 70% transparent. How to do the same with only the last visible slider block?
<div class="slider-container">
<div><img src="img/slider-1.png" alt=""></div>
<div><img src="img/slider-2.png" alt=""></div>
<div><img src="img/slider-3.png" alt=""></div>
<div><img src="img/slider-4.png" alt=""></div>
<div><img src="img/slider-5.png" alt=""></div>
<div><img src="img/slider-6.png" alt=""></div>
<div><img src="img/slider-1.png" alt=""></div>
<div><img src="img/slider-2.png" alt=""></div>
<div><img src="img/slider-3.png" alt=""></div>
<div><img src="img/slider-4.png" alt=""></div>
<div><img src="img/slider-5.png" alt=""></div>
<div><img src="img/slider-6.png" alt=""></div>
</div>
<script>
$(document).ready(function(){
$('.slider-container').slick({
slidesToShow: 5,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 2000,
});
});
</script>
.slick-current img{
transition: all .3s;
opacity: 0.3;
}
Answer the question
In order to leave comments, you need to log in
For fun, it might make you think
jQuery('.slider-container').children('.slick-slide').css('opacity', 1);
jQuery('.slider-container').children('.slick-slide.slick-active').last().css('opacity', 0.4);
.slick-slide.slick-active:last-of-type {
opacity: 0.4;
}
Have you tried the ::last-child option? Or did it not work?
htmlbook.ru/css/last-child
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question