我在网格中使用SwiperJS时遇到了一个问题。当我将Swiper Package 放入with display中时:网格时, Package 器溢出100%。我提供了一个指向我的JSFiddle示例的链接。如果你删除CSS,你会看到一切正常。但是,当我添加网格时,问题就出现了。
谢谢你。
jsfiddle
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.css"
/>
<div class="item-grid">
<div>
<div 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>
</div>
</div>
<div></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.js"></script>
<script>
var swiper = new Swiper(".mySwiper", {
slidesPerView: 6,
spaceBetween: 30,
pagination: {
el: ".swiper-pagination",
clickable: true,
},
});
</script>
.item-grid {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 24px;
}
2条答案
按热度按时间ruarlubt1#
您可以将包含滑动器的网格项的最小宽度设置为100%。
drkbr07n2#
你可以用flex代替grid。
使用此样式。