gpt4 book ai didi

javascript - 使显示下一个/上一个响应的一部分的旋转木马

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

我有一个显示下一张和上一张图片的部分内容的轮播,但目前它对超过移动尺寸的任何内容都没有响应。这是代码:

<style>
.item img:first-child,
.item img:last-child {
display: none;
}
/* Small devices (tablets, 768px and up) */
@media (min-width: 768px) {
.item img {
float: left;
/*width: 600px;*/
}
.item img:first-child,
.item img:last-child {
display: block;
}
.item.active {
overflow: hidden;
margin: 0 -546px;
}
}
/* Medium devices (desktops, 992px and up) */
@media (min-width: 992px) {
.item img {
/*width: 600px;*/
}
.item.active {
margin: 0 -434px;
}
}
/* Large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
.item img {
/*width: 600px;*/
}
.item.active {
margin: 0 -427px;
}
}

.carousel-inner .active.left { left: -33%; }
.carousel-inner .next { left: 33%; }
.carousel-inner .prev { left: -33%; }

</style>

<div class="container-fluid no-pad">
<div class="row">
<div class="col-lg-12 no-pad">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div align="center" class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
</div>
<div class="item">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
</div>
<div class="item">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
</div>
<div class="item">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
</div>
<div class="item">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
</div>
<div class="item">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
<img src="http://placehold.it/1148x780" alt="Chania" class="img-responsive">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>

我希望轮播缩小(这就是我添加 img-responsive BS 类的原因)。但目前它保持相同的大小

最佳答案

我希望这是您正在寻找的,我已经简化了您的 CSS:

.item img {
float:left;
max-width:33.33% !important;
}

@media (max-width: 768px) {

.item img {
max-width:100% !important;
}

.item img:first-child,
.item img:last-child {
display: none !important;
}

}


.carousel-inner .active.left { left: -33%; }
.carousel-inner .next { left: 33%; }
.carousel-inner .prev { left: -33%; }

Check the JSFiddle result here.

关于javascript - 使显示下一个/上一个响应的一部分的旋转木马,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34675484/

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