Quiero un comportamiento como el de esta página web de airbnb. Concretamente, el de la siguiente imagen.
Como puede ver, en los bordes del carrusel, tiene un efecto de desvanecimiento solo en las diapositivas que están cortadas.
Esto es lo que tengo hasta ahora: https://jsfiddle.net/gpu5cafz/ .
HTML (asegúrese de instalar Swiper si no está usando jsfiddle):
<div class="container"> <div class="swiper"> <!-- Additional required wrapper --> <div class="swiper-wrapper"> <!-- Slides --> <div class="swiper-slide">Slide 1</div> <div class="swiper-slide">Slide 2</div> <div class="swiper-slide">Slide 3</div> <div class="swiper-slide">Slide 4</div> <div class="swiper-slide">Slide 5</div> </div> </div> </div>CSS:
.swiper-slide { width: 300px !important; height: 200px !important; text-decoration: none; background-color: gray; border-radius: 10px; color: white; background: rgb(203, 203, 203); } .container { padding: 60px 120px 60px 120px; }JS:
const swiper = new Swiper('.swiper', { slidesPerView: 'auto', spaceBetween: 30, freeMode: true, freeModeSticky: false, watchSlidesProgress: true, watchSlidesVisibility: true, });Tienes razón, no era exactamente lo que buscabas. Estás buscando este tipo de solución:
<title>My Example</title> <style> div { background: linear-gradient(to right, white 20%, grey, white 80%); color: white; padding: 30px; height: 160px; font-family: sans-serif; font-size: 1.5em; } </style> <div> Three color stops. </div>``` I think in the end your gonna end up in this ballpark. I am not 100% sure how to get your exact endresult (they seem to use some kind of animation feature too). But maybe someone else can supplement. This example I am giving you here is based on what I built for a customer once where they had an image in the middle and they wanted to have a background color left/right and then have it fade out as it got closer to the middle of the screen.Considere el uso de degradados en la propiedad de la mask .
Por ejemplo,
.container { mask-image: linear-gradient(to right, transparent 0%, black 20% 80%, transparent 100%); }