Can the Twitter Bootstrap Carousel plugin fade in and out on slide transition

前端 未结 6 1156
时光取名叫无心
时光取名叫无心 2020-11-30 19:36

I have a very basic implementation of the Twitter Bootstrap Carousel plugin on a site that I am working on (http://furnitureroadshow.com/). I was just wondering if anyone h

6条回答
  •  -上瘾入骨i
    2020-11-30 20:09

    Note: If you are using Bootstrap + AngularJS + UI Bootstrap, .left .right and .next classes are never added. Using the example at the following link and the CSS from Robert McKee answer works. I wanted to comment because it took 3 days to find a full solution. Hope this helps others!

    https://angular-ui.github.io/bootstrap/#/carousel

    Code snip from UI Bootstrap Demo at the above link.

    angular.module('ui.bootstrap.demo').controller('CarouselDemoCtrl', function ($scope) {
      $scope.myInterval = 5000;
      var slides = $scope.slides = [];
      $scope.addSlide = function() {
        var newWidth = 600 + slides.length + 1;
        slides.push({
          image: 'http://placekitten.com/' + newWidth + '/300',
          text: ['More','Extra','Lots of','Surplus'][slides.length % 4] + ' ' +
            ['Cats', 'Kittys', 'Felines', 'Cutes'][slides.length % 4]
        });
      };
      for (var i=0; i<4; i++) {
        $scope.addSlide();
      }
    });
    

    Html From UI Bootstrap, Notice I added the .fade class to the example.

    CSS from Robert McKee's answer above

    .carousel.fade {
    opacity: 1;
    }
    .carousel.fade .item {
    -moz-transition: opacity ease-in-out .7s;
    -o-transition: opacity ease-in-out .7s;
    -webkit-transition: opacity ease-in-out .7s;
    transition: opacity ease-in-out .7s;
    left: 0 !important;
    opacity: 0;
    top:0;
    position:absolute;
    width: 100%;
    display:block !important;
    z-index:1;
    }
    .carousel.fade .item:first-child {
    top:auto;
    position:relative;
    }
    .carousel.fade .item.active {
    opacity: 1;
    -moz-transition: opacity ease-in-out .7s;
    -o-transition: opacity ease-in-out .7s;
    -webkit-transition: opacity ease-in-out .7s;
    transition: opacity ease-in-out .7s;
    z-index:2;
    }
    /*
    Added z-index to raise the left right controls to the top
    */
    .carousel-control {
    z-index:3;
    }
    

提交回复
热议问题