next.js 我需要用React JS创建一个滑块

fkvaft9z  于 2023-11-18  发布在  React
关注(0)|答案(2)|浏览(121)


的数据
我的设计,但我不知道如何做到这一步
我尝试不同的配置与swiper和光滑的幻灯片

我的代码这样,但


这是我的结果

yduiuuwa

yduiuuwa1#

在容器的左边和右边,你可以使用::after::before伪选择器添加不透明度、模糊或渐变。

imzjd6km

imzjd6km2#

此效果与Swiper API无关(是.swiper的某个transparent edges)。
最简单的方法是添加css mask

.swiper {
  /* MASK */
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 1) 20%, rgba(0, 0, 0, 1) 80%, transparent 100%)
}

字符串

**最好通过媒体查询在移动的上禁用。

Demo:

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"/>

的字符串

相关问题