jQuery 如何更改滑动动画以在 Bootstrap3 Carousel 上通过过渡淡入/淡出

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19231678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 23:29:11  来源:igfitidea点击:

How can I change the sliding animation to fade in/out with transition on Bootstrap3 Carousel

jquerycsstwitter-bootstraptwitter-bootstrap-3

提问by asifsaho

I was trying to change the sliding effect of bootstrap 3 carousel to fade in/out. I followed the instruction given here Can the Twitter Bootstrap Carousel plugin fade in and out on slide transition

我试图将 bootstrap 3 carousel 的滑动效果更改为淡入/淡出。我按照这里给出的说明Twitter Bootstrap Carousel 插件可以在幻灯片过渡时淡入淡出吗

the css code is (said in the link) below

css代码是(在链接中说的)下面

.carousel .item {
    -webkit-transition: opacity 3s; 
    -moz-transition: opacity 3s; 
    -ms-transition: opacity 3s; 
    -o-transition: opacity 3s; 
    transition: opacity 3s;
}
.carousel .active.left {
    left:0;
    opacity:0;
    z-index:2;
}
.carousel .next {
    left:0;
    opacity:1;
    z-index:1;
}

My example link is at the end of of this pagragraph, I am making it but problem is the previous button isn't working perfectly, may be the solution is perfect for bootstrap2, I am using bootstrap3, can anybody help me? Advance Thanks for your help. I am new here, very sorry for my poor English and if I asked a stupid question!

我的示例链接在本页的末尾,我正在制作,但问题是前一个按钮无法正常工作,可能该解决方案非常适合 bootstrap2,我正在使用 bootstrap3,有人可以帮助我吗?提前感谢您的帮助。我是新来的,很抱歉我的英语很差,如果我问了一个愚蠢的问题!

https://dl.dropboxusercontent.com/u/35758776/xenxbd/contrastic/index.html#parallux-wrapper-04

https://dl.dropboxusercontent.com/u/35758776/xenxbd/contraastic/index.html#parallux-wrapper-04

回答by Zim

Try this carousel fade example. It will show you how to change opacity for prev and next buttons.

试试这个轮播淡入淡出的例子。它将向您展示如何更改上一个和下一个按钮的不透明度。

.carousel-fade .carousel-inner .item {
  opacity: 0;
  -webkit-transition-property: opacity;
  -moz-transition-property: opacity;
  -o-transition-property: opacity;
  transition-property: opacity;
}
.carousel-fade .carousel-inner .active {
  opacity: 1;
}
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
  left: 0;
  opacity: 0;
  z-index: 1;
}
.carousel-fade .carousel-inner .next.left,
.carousel-fade .carousel-inner .prev.right {
  opacity: 1;
}
.carousel-fade .carousel-control {
  z-index: 2;
}

http://bootply.com/86170

http://bootply.com/86170

回答by Flavio Salas

Add class ".carousel-fade" in your carousel. css:

在您的轮播中添加类“.carousel-fade”。css:

.carousel-fade .active.left {
        left:0;
        opacity:0;
        -webkit-transition: opacity 1s; /*time < to $.carousel.interval setup */
        -moz-transition: opacity 1s; 
        -ms-transition: opacity1s; 
        -o-transition: opacity 1s; 
        transition: opacity  1s;
        z-index:2;

}

.carousel-fade .next {

    left:0;
    opacity:1;
    z-index:1;

}