Bootstrap 4 Carousel Show 2 Slides Advance 1

后端 未结 2 1828
孤独总比滥情好
孤独总比滥情好 2021-01-28 13:19

I\'m trying to show two slides on a Bootstrap 4 carousel while only advancing 1 when next or prev is clicked. It\'s doing it now but when it does, it doesn\'t smoothly slide ove

相关标签:
2条回答
  • 2021-01-28 13:41

    It is working as expected (one at a time) but because the images are all the same it's hard to see. Try with different images like this...

    https://www.bootply.com/9YTnuqUPMs

    To make the animation more Bootstrap 4 friendly, override the transitions like this...

    .carousel-inner .carousel-item-left.active {
      transform: translateX(-50%);
    }
    .carousel-inner .carousel-item-right.active {
      transform: translateX(50%);
    }
    
    .carousel-inner .carousel-item-next {
      transform: translateX(50%)
    }
    .carousel-inner .carousel-item-prev {
      transform: translateX(-50%)
    }
    
    .carousel-inner .carousel-item-right,
    .carousel-inner .carousel-item-left{ 
      transform: translateX(0);
    }
    

    https://www.bootply.com/G33EYIj4eF


    Also see: https://stackoverflow.com/a/20008623/171456

    0 讨论(0)
  • 2021-01-28 13:48

    I see what's wrong. If you want to have the same result as the first one, you will change:

    <div class="carousel-item">
    <img class="d-block col-6 img-fluid" src="http://placehold.it/350x150">
    <img class="d-block col-6 img-fluid" src="http://placehold.it/350x150">
    </div>
    

    Two pictures in one carousel-item.

    0 讨论(0)
提交回复
热议问题