我正在制作一个Bootstrap旋转木马,我希望每个旋转木马项目都是两个并排的图像。旋转木马旋转时,应显示不同的双图像项目。
目前,我在旋转木马中有三个项目。旋转木马显示并旋转,但在第一次旋转时,所有项目都会在屏幕外显示并且不会返回。
任何人都可以帮我弄清楚为什么以及如何解决它?
这是一个Codepen:https://codepen.io/lieberscott/pen/mxZQmp?editors=1100
这是我的HTML:
<div class="container">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel" data-wrap="true">
<div class="carousel-inner">
<div class="carousel-item active">
<div class="row">
<div class="col-6">
<img class="d-block w-100" src="https://scottlieber.files.wordpress.com/2018/04/statehouseblue.jpg" alt="First slide">
</div>
<div class="col-6">
<img class="d-block w-100" src="https://scottlieber.files.wordpress.com/2018/04/statehouseblue.jpg" alt="First slide">
</div>
</div>
<div class="carousel-item">
<div class="row">
<div class="col-6">
<img class="d-block w-100" src="https://scottlieber.files.wordpress.com/2018/04/reallives.jpg" alt="First slide">
</div>
<div class="col-6">
<img class="d-block w-100" src="https://scottlieber.files.wordpress.com/2018/04/reallives.jpg" alt="First slide">
</div>
</div>
</div>
<div class="carousel-item">
<div class="row">
<div class="col-6">
<img class="d-block w-100" src="https://scottlieber.files.wordpress.com/2018/04/reallives.jpg" alt="First slide">
</div>
<div class="col-6">
<img class="d-block w-100" src="https://scottlieber.files.wordpress.com/2018/04/reallives.jpg" alt="First slide">
</div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
答案 0 :(得分:0)
那将是一种可能的解决方案
<div class="container">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<div class="row">
<img class="col-6" src="https://scottlieber.files.wordpress.com/2018/04/statehouseblue.jpg" alt="First slide"></img>
<img class="col-6" src="https://scottlieber.files.wordpress.com/2018/04/statehouseblue.jpg" alt="First slide"></img>
</div>
</div>
<div class="carousel-item">
<div class="row">
<img class="col-6" src="https://scottlieber.files.wordpress.com/2018/04/reallives.jpg" alt="First slide"></img>
<img class="col-6" src="https://scottlieber.files.wordpress.com/2018/04/reallives.jpg" alt="First slide"></img>
</div>
</div>
<div class="carousel-item">
<div class="row">
<img class="col-6" src="https://scottlieber.files.wordpress.com/2018/04/statehouseblue.jpg" alt="First slide"></img>
<img class="col-6" src="https://scottlieber.files.wordpress.com/2018/04/statehouseblue.jpg" alt="First slide"></img>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>