我正在使用bootstrap 4滑块。我要在引导滑块中的第一项处于活动状态时更改主体的背景颜色。并且如果其他任何项目处于活动状态,则主体颜色将正常显示。enter image description here
.carousel-item{ width:100%; height:400px; background-color:red; text-align:center; line-height:400px; font-size:100px; color:#fff;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<div id="demo" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1"></li>
<li data-target="#demo" data-slide-to="2"></li>
</ul>
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active"> 1 </div>
<div class="carousel-item"> 2 </div>
<div class="carousel-item"> 3 </div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#demo" data-slide="prev"> <span class="carousel-control-prev-icon"></span> </a> <a class="carousel-control-next" href="#demo" data-slide="next"> <span class="carousel-control-next-icon"></span> </a> </div>
</body>
答案 0 :(得分:0)
使用轮播回调
apples=["green","red","yellow"]
您可以在此处找到文档:https://getbootstrap.com/docs/4.0/components/carousel/#events