gpt4 book ai didi

javascript - 如何使用淡入淡出效果自定义 bootstrap carousel

转载 作者:太空宇宙 更新时间:2023-11-04 07:52:27 25 4
gpt4 key购买 nike

这是我的 carousal 的 html 代码

  <section id="showcase">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item carousel-image-1 active">
<div class="container">
<div class="carousel-caption d-none d-sm-block text-right mb-5">
<h1 class="display-3">Heading One</h1>
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus illum commodi enim consequatur nesciunt voluptatum perspiciatis sint. Nemo, modi nulla.</p>
<a href="#" class="btn btn-danger btn-lg">Sign Up Now</a>
</div>
</div>
</div>

<div class="carousel-item carousel-image-2">
<div class="container">
<div class="carousel-caption d-none d-sm-block mb-5">
<h1 class="display-3">Heading Two</h1>
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus illum commodi enim consequatur nesciunt voluptatum perspiciatis sint. Nemo, modi nulla.</p>
<a href="#" class="btn btn-primary btn-lg">Learn More</a>
</div>
</div>
</div>

<div class="carousel-item carousel-image-3">
<div class="container">
<div class="carousel-caption d-none d-sm-block text-right mb-5">
<h1 class="display-3">Heading Three</h1>
<p class="lead">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Natus illum commodi enim consequatur nesciunt voluptatum perspiciatis sint. Nemo, modi nulla.</p>
<a href="#" class="btn btn-success btn-lg">Learn More</a>
</div>
</div>
</div>
</div>

<a href="#myCarousel" data-slide="prev" class="carousel-control-prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a href="#myCarousel" data-slide="next" class="carousel-control-next">
<span class="carousel-control-next-icon"></span>
</a>
</div>

我想为这张幻灯片设置淡入淡出效果。任何人都可以帮助我制作我的 css 代码。我找到了一些像这样的旋转木马的 css 代码。

但它无法正常工作。

     .carousel-fade .carousel-inner .item {
-webkit-transition-property: opacity;
transition-property: opacity;
}
.carousel-fade .carousel-inner .item,
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
opacity: 0;
}
.carousel-fade .carousel-inner .active,
.carousel-fade .carousel-inner .next.left,
.carousel-fade .carousel-inner .prev.right {
opacity: 1;
}
.carousel-fade .carousel-inner .next,
.carousel-fade .carousel-inner .prev,
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
left: 0;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.carousel-fade .carousel-control {
z-index: 2;
}
html,
body,
.carousel,
.carousel-inner,
.carousel-inner .item
{
height: 100%;
}
.item:nth-child(1) {
background: url("../img/img2.jpeg");
background-size: cover;
}
}
.item:nth-child(2) {
background: url("../img/img2.jpeg");
background-size: cover;
}
}
.item:nth-child(3) {
background: url("../img/img2.jpeg");
background-size: cover;
}
}

我想为我的 bootstrap carousal 编辑这个 css 代码。

如果有人知道另一种淡入淡出的方法,请帮助我。

最佳答案

试试这个。希望对您有所帮助

.carousel .item {
-webkit-transition: opacity 0.5s ease-in-out;
-moz-transition: opacity 0.5s ease-in-out;
-ms-transition: opacity 0.5s ease-in-out;
-o-transition: opacity 0.5s ease-in-out;
transition: opacity 0.5s ease-in-out;
opacity:0;
}

.carousel .active.item {
opacity:1;
}

.carousel.carousel-fade .active.left,
.carousel.carousel-fade .active.right {
left: 0;
z-index: 2;
opacity: 0;
filter: alpha(opacity=0);
}

.carousel.carousel-fade .next,
.carousel.carousel-fade .prev {
left: 0;
z-index: 1;
}

.carousel.carousel-fade .carousel-control {
z-index: 3;
}

关于javascript - 如何使用淡入淡出效果自定义 bootstrap carousel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47632302/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com