的数据我的设计,但我不知道如何做到这一步我尝试不同的配置与swiper和光滑的幻灯片我的代码这样,但
这是我的结果
yduiuuwa1#
在容器的左边和右边,你可以使用::after和::before伪选择器添加不透明度、模糊或渐变。
::after
::before
imzjd6km2#
此效果与Swiper API无关(是.swiper的某个transparent edges)。最简单的方法是添加css mask。
.swiper
transparent edges
.swiper { /* MASK */ -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 1) 20%, rgba(0, 0, 0, 1) 80%, transparent 100%) }
字符串
**最好通过媒体查询在移动的上禁用。
var swiper = new Swiper(".mySwiper", { slidesPerView: 4, spaceBetween: 30, mousewheel: true, centeredSlides: true, loop: true, pagination: { el: ".swiper-pagination", clickable: true, }, });
x
html, body { position: relative; height: 100%; } body { background: lightblue; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; color: #000; margin: 0; padding: 0; } .swiper { width: 100%; height: 100%; max-width: 900px; margin: auto; /* MASK */ -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 1) 20%, rgba(0, 0, 0, 1) 80%, transparent 100%) } .swiper-slide { text-align: center; font-size: 18px; background: #fff; display: flex; justify-content: center; align-items: center; }
<script src="https://cdn.jsdelivr.net/npm/[email protected]/swiper-bundle.min.js"></script> <!-- Swiper --> <main class="swiper mySwiper"> <div class="swiper-wrapper"> <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 class="swiper-slide">Slide 6</div> <div class="swiper-slide">Slide 7</div> <div class="swiper-slide">Slide 8</div> <div class="swiper-slide">Slide 9</div> </div> <div class="swiper-pagination"></div> </main> </script> <link href="https://cdn.jsdelivr.net/npm/[email protected]/swiper-bundle.min.css" rel="stylesheet"/>
的字符串
2条答案
按热度按时间yduiuuwa1#
在容器的左边和右边,你可以使用
::after
和::before
伪选择器添加不透明度、模糊或渐变。imzjd6km2#
此效果与Swiper API无关(是
.swiper
的某个transparent edges
)。最简单的方法是添加css mask。
字符串
**最好通过媒体查询在移动的上禁用。
Demo:
x
的字符串