Bootstrap 轮播照片列表不工作
Bootstrap carousel photos list not working
我目前正在尝试向我正在为某人制作的网站添加一个 bootstrap 轮播,每次我添加照片或标题时,照片要么在列表中排列,要么字幕堆叠在一起。有人可以帮忙吗?
网站是这样的:
堆叠在一起的照片:
带有 <h3>
和 <h4>
字符串的标题看起来像什么:
这是一小段代码(我使用了 bootstrap 在他们网站上的模板):
<section class="container">
<div class="row">
<div class="col-sm-12">
<div id="my-slider" class="carousel slide col-sm-12" data-ride="carousel">
<!-- indicators -->
<ol class="carousel-indicators">
<li data-target="#my-slide" data-slide-to="0" class="active"></li>
<li data-target="#my-slide" data-slide-to="1"></li>
<li data-target="#my-slide" data-slide-to="2"></li>
<li data-target="#my-slide" data-slide-to="3"></li>
</ol>
<!-- wrappers -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="" alt=""/>
<div class="carousel-caption">
<h3>Flutes of the World Concert</h3>
<h5>with Tereasa Payne</h5>
</div>
</div>
<div class="item">
<img id="img" src="img/RPO_Siku.jpg" alt="siku"/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="item">
<img id="img" src="img/RPO_Nose_Flute_Laughing.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="item">
<img id="img" src="img/RPO_playing_Toyo.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="item">
<img src="img/RPO_Native_American_Flute.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
</div>
<!-- controls -->
<a class="left carousel-control" href="#my-slider" 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="#my-slider" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</section>
不允许将 Bootstrap 列直接嵌套在其他 Bootstrap 列中。
Bootstrap 列必须始终有一个 Bootstrap row
作为父级。
参考:
https://getbootstrap.com/docs/4.0/layout/grid/#nesting
https://getbootstrap.com/docs/4.0/components/carousel/#with-captions
此外,Bootstrap 4.
中没有字形
在 bootstrap 4 每张幻灯片都应该有一个 class carousel-item
而不是 item
作为 bootstrap 3 ,
也因为@WebDevbooster mentiened boostrap 4 不包括字体 awsome 所以你控制使用 carousel-control-prev
用于上一个控制和 carousel-control-next 用于下一个:
请参阅下面的工作片段:
.carousel-inner img {
width: 100%;
height: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<section class="container">
<div class="row">
<div class="col-sm-12">
<div id="my-slider" class="carousel slide" data-ride="carousel">
<!-- indicators -->
<ol class="carousel-indicators">
<li data-target="#my-slider" data-slide-to="0" class="active"></li>
<li data-target="#my-slider" data-slide-to="1"></li>
<li data-target="#my-slider" data-slide-to="2"></li>
<li data-target="#my-slider" data-slide-to="3"></li>
</ol>
<!-- wrappers -->
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img id="img" src="https://www.w3schools.com/bootstrap4/chicago.jpg" alt="siku"/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="carousel-item">
<img id="img" src="https://www.w3schools.com/bootstrap4/ny.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="carousel-item">
<img id="img" src="https://www.w3schools.com/bootstrap4/la.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="carousel-item">
<img src="https://www.w3schools.com/bootstrap4/la.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
</div>
<!-- controls -->
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#my-slider" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#my-slider" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</div>
</div>
</section>
我目前正在尝试向我正在为某人制作的网站添加一个 bootstrap 轮播,每次我添加照片或标题时,照片要么在列表中排列,要么字幕堆叠在一起。有人可以帮忙吗?
网站是这样的:
堆叠在一起的照片:
带有 <h3>
和 <h4>
字符串的标题看起来像什么:
这是一小段代码(我使用了 bootstrap 在他们网站上的模板):
<section class="container">
<div class="row">
<div class="col-sm-12">
<div id="my-slider" class="carousel slide col-sm-12" data-ride="carousel">
<!-- indicators -->
<ol class="carousel-indicators">
<li data-target="#my-slide" data-slide-to="0" class="active"></li>
<li data-target="#my-slide" data-slide-to="1"></li>
<li data-target="#my-slide" data-slide-to="2"></li>
<li data-target="#my-slide" data-slide-to="3"></li>
</ol>
<!-- wrappers -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="" alt=""/>
<div class="carousel-caption">
<h3>Flutes of the World Concert</h3>
<h5>with Tereasa Payne</h5>
</div>
</div>
<div class="item">
<img id="img" src="img/RPO_Siku.jpg" alt="siku"/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="item">
<img id="img" src="img/RPO_Nose_Flute_Laughing.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="item">
<img id="img" src="img/RPO_playing_Toyo.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="item">
<img src="img/RPO_Native_American_Flute.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
</div>
<!-- controls -->
<a class="left carousel-control" href="#my-slider" 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="#my-slider" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</section>
不允许将 Bootstrap 列直接嵌套在其他 Bootstrap 列中。
Bootstrap 列必须始终有一个 Bootstrap row
作为父级。
参考:
https://getbootstrap.com/docs/4.0/layout/grid/#nesting
https://getbootstrap.com/docs/4.0/components/carousel/#with-captions
此外,Bootstrap 4.
中没有字形在 bootstrap 4 每张幻灯片都应该有一个 class carousel-item
而不是 item
作为 bootstrap 3 ,
也因为@WebDevbooster mentiened boostrap 4 不包括字体 awsome 所以你控制使用 carousel-control-prev
用于上一个控制和 carousel-control-next 用于下一个:
请参阅下面的工作片段:
.carousel-inner img {
width: 100%;
height: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<section class="container">
<div class="row">
<div class="col-sm-12">
<div id="my-slider" class="carousel slide" data-ride="carousel">
<!-- indicators -->
<ol class="carousel-indicators">
<li data-target="#my-slider" data-slide-to="0" class="active"></li>
<li data-target="#my-slider" data-slide-to="1"></li>
<li data-target="#my-slider" data-slide-to="2"></li>
<li data-target="#my-slider" data-slide-to="3"></li>
</ol>
<!-- wrappers -->
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img id="img" src="https://www.w3schools.com/bootstrap4/chicago.jpg" alt="siku"/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="carousel-item">
<img id="img" src="https://www.w3schools.com/bootstrap4/ny.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="carousel-item">
<img id="img" src="https://www.w3schools.com/bootstrap4/la.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
<div class="carousel-item">
<img src="https://www.w3schools.com/bootstrap4/la.jpg" alt=""/>
<div class="carousel-caption">
<h4></h4>
<h5></h5>
</div>
</div>
</div>
<!-- controls -->
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#my-slider" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#my-slider" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</div>
</div>
</section>