I'm using Ken Wheeler's plugin, Slick carousel, and as you can see in the image below, when a slide is sliding at the edge, it looks like it's being cut off. I'm thinking of a "fading edge", in which when a slide slides at the edge, it has a "softer" effect. Instead of this abrupt slide disappearance, a gradual (just like a fade effect) one. Is there any way to do it?
$('.carousel').slick({
arrows: false,
autoplay: true,
autoplaySpeed: 1000,
speed: 2000,
slidesToShow: 5,
slidesToScroll: 1,
responsive: [{
breakpoint: 1024,
settings: {
slidesToShow: 4
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 3
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 2
}
}
]
});
.container {
padding: 40px;
background-color: blue;
}
.slick-slide {
margin: 0px 20px;
}
.slick-slide img {
width: 100%;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.js"></script>
<script src="main.js"></script>
<div class='container'>
<div class='carousel'>
<div>
<a href="#"><img src="http://i.imgur.com/kkVWQR4.jpg" alt=""></a>
</div>
<div>
<a href="#"><img src="http://i.imgur.com/RRWm3lB.jpg" alt=""></a>
</div>
<div>
<a href="#"><img src="http://i.imgur.com/2f2pUHi.jpg" alt=""></a>
</div>
<div>
<a href="#"><img src="http://i.imgur.com/7TSiIkS.jpg" alt=""></a>
</div>
<div>
<a href="#"><img src="http://i.imgur.com/dXxnAnC.jpg" alt=""></a>
</div>
<div>
<a href="#"><img src="http://i.imgur.com/kkVWQR4.jpg" alt=""></a>
</div>
<div>
<a href="#"><img src="http://i.imgur.com/RRWm3lB.jpg" alt=""></a>
</div>
<div>
<a href="#"><img src="http://i.imgur.com/2f2pUHi.jpg" alt=""></a>
</div>
<div>
<a href="#"><img src="http://i.imgur.com/7TSiIkS.jpg" alt=""></a>
</div>
<div>
<a href="#"><img src="http://i.imgur.com/dXxnAnC.jpg" alt=""></a>
</div>
</div>
</div>
You can get pretty close with background: linear-gradient();
with :before
+ :after
pseudo elements, but the link won't be clickable for any area gets covered. Just update the width
and rgba()
colors as needed.
UPDATE:
In order to make the links to be clickable even when they get covered, you can simply add pointer-events: none;
to the pseudo element.
.carousel:before,
.carousel:after {
content: "";
position: absolute;
z-index: 1;
width: 100px;
top: 0;
height: 100%;
pointer-events: none; /*makes the linkes behind clickable.*/
}
.carousel:before {
left: 0;
background: linear-gradient(to right, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
}
.carousel:after {
right: 0;
background: linear-gradient(to left, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
}
jsFiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With