简体   繁体   English

多项目轮播

[英]Multi item carousel

I have this working example Multi Item Carousel where I have 4 items next to each other (on resolution 1200px or more), and I would like to change it to 7 smaller items. 我有这个工作示例“ 多项目轮播” ,其中我彼此相邻有4个项目(分辨率为1200px或更高),我想将其更改为7个较小的项目。

I have tried to add 我试图添加

.active > div:first-child + div + div + div + div { display:block; } 

in the /*lg*/ section in css (below line 72) and I also increased range in JS (line 8) like this css/*lg*/部分(在第72行以下)中,我也在JS (第8行)中增大了范围,如下所示

for (var i = 0; i < 4; i++) {

And also I added more items in html, so that I have 7 而且我在html中添加了更多项目,因此我有7

<div class="item">
    <div class="carousel-col">
        <div class="block yellow img-responsive"></div>
    </div>
</div>

But that did not help, it just added 1 item + 2 when slide occurs, in the next row. 但这无济于事,它仅在下一行出现幻灯片时添加了1项+ 2。

What am I missing? 我想念什么?

Change the CSS in the /*lg*/ section to /*lg*/部分中的CSS更改为

@media (min-width: 1200px) {
  .carousel-inner .active.left { left: -14.28%; }
  .carousel-inner .active.right{ left:  14.28%; }
  .carousel-inner .next        { left:  14.28%; }
  .carousel-inner .prev        { left: -14.28%; }
  .carousel-col                { width: 14.28%; }
  .active > div:first-child + div { display:block; }
  .active > div:first-child + div + div { display:block; }
  .active > div:first-child + div + div + div { display:block; }
  .active > div:first-child + div + div + div + div{ display:block; }
  .active > div:first-child + div + div + div + div + div{ display:block; }
  .active > div:first-child + div + div + div + div + div + div + div { display:block; }
}

And change the JavaScript range to for (var i = 0; i < 7; i++) { . 并将JavaScript范围更改为for (var i = 0; i < 7; i++) {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM