gpt4 book ai didi

html - Bootstrap 4 Multiple Item Carousel(点击循环所有新元素)

转载 作者:行者123 更新时间:2023-12-04 16:34:39 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Bootstrap 4 Carousel Show 2 Slides Advance 1

(2 个回答)



Bootstrap carousel multiple frames at once

(15 个回答)



Bootstrap 4 Multi Carousel show 4 images instead of 3

(1 个回答)


3年前关闭。




尝试使用 bootstrap 4 carousel 功能来执行此操作(下图是 bootstrap 3 variant)

enter image description here

我尝试将其转换为 bootstrap 4。我对它所做的是通过 bootstrap 3 → to bootstrap 4 html conversion tool 运行它。在 html 上,并调整对来自 CDN 的 Bootstrap JS 和 CSS 文件的引用。我还用颜色更改了图像引用,以便更容易区分我想要显示的图像。

下面是代码,它没有在一张幻灯片上显示所有 4 个图像

$(document).ready(function() {
$('#Carousel').carousel({
interval: 5000
})
});
body{padding-top:20px;}
.carousel {
margin-bottom: 0;
padding: 0 40px 30px 40px;
}
/* The controlsy */
.carousel-control {
left: -12px;
height: 40px;
width: 40px;
background: none repeat scroll 0 0 #222222;
border: 4px solid #FFFFFF;
border-radius: 23px 23px 23px 23px;
margin-top: 90px;
}
.carousel-control.right {
right: -12px;
}
/* The indicators */
.carousel-indicators {
right: 50%;
top: auto;
bottom: -10px;
margin-right: -19px;
}
/* The colour of the indicators */
.carousel-indicators li {
background: #cecece;
}
.carousel-indicators .active {
background: #428bca;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<!------ Include the above in your HEAD tag ---------->

<div class="container">
<div class="row">
<div class="col-lg-12">
<div id="Carousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#Carousel" data-slide-to="0" class="active"></li>
<li data-target="#Carousel" data-slide-to="1"></li>
<li data-target="#Carousel" data-slide-to="2"></li>
</ol>
<!-- Carousel items -->
<div class="carousel-inner">
<div class="item active carousel-item">
<div class="row">
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250/0ff" alt="Image" style="max-width:100%;"></a>
</div>
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250/0ff" alt="Image" style="max-width:100%;"></a>
</div>
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250/0ff" alt="Image" style="max-width:100%;"></a>
</div>
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250/0ff" alt="Image" style="max-width:100%;"></a>
</div>
</div>
<!--.row-->
</div>
<!--.item-->
<div class="item carousel-item">
<div class="row">
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250/00f" alt="Image" style="max-width:100%;"></a>
</div>
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250/00f" alt="Image" style="max-width:100%;"></a>
</div>
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250/00f" alt="Image" style="max-width:100%;"></a>
</div>
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250/00f" alt="Image" style="max-width:100%;"></a>
</div>
</div>
<!--.row-->
</div>
<!--.item-->
<div class="item carousel-item">
<div class="row">
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;"></a>
</div>
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;"></a>
</div>
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;"></a>
</div>
<div class="col-lg-3"><a href="#" class="thumbnail"><img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;"></a>
</div>
</div>
<!--.row-->
</div>
<!--.item-->
</div>
<!--.carousel-inner--><a data-slide="prev" href="#Carousel" class="left carousel-control">&#x2039;</a>
<a data-slide="next" href="#Carousel" class="right carousel-control">&#x203A;</a>
</div>
<!--.Carousel-->
</div>
</div>
</div>
<!--.container-->

最佳答案

用 4 个元素检查这个 bootstrap v4 轮播:

.col-md-3{
display: inline-block;
margin-left:-4px;
}
.col-md-3 img{
width:100%;
height:auto;
}
body .carousel-indicators li{
background-color:red;
}
body .carousel-indicators{
bottom: 0;
}
body .carousel-control-prev-icon,
body .carousel-control-next-icon{
background-color:red;
}
body .no-padding{
padding-left: 0;
padding-right: 0;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<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="container carousel-inner no-padding">
<div class="carousel-item active">
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
</div>
<div class="carousel-item">
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
</div>
<div class="carousel-item">
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="https://image.shutterstock.com/z/stock-photo-sleeping-disorders-as-a-reason-for-insomnia-293777093.jpg">
</div>
</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>


您也可以查看这支笔 https://codepen.io/kravisingh/pen/pLGzgo

关于html - Bootstrap 4 Multiple Item Carousel(点击循环所有新元素),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49739299/

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