我使用了简单的网格<div class="col-lg-6">
,但没有工作,只是在图片下推送了描述。
谢谢!
<div id="demo" class="carousel slide" data-ride="carousel">
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active">
<div class="col-lg-6">
<img src="http://lorempixel.com/400/200/" alt="Los Angeles" width="400" height="200">
</div>
<div class="col-lg-6">
<h3>Firste caption</h3>
<p>Loren ipsun</p>
</div>
</div>
<div class="carousel-item ">
<div class="col-lg-6">
<img src="http://lorempixel.com/400/200/" alt="Los Angeles" width="400" height="200">
</div>
<div class="col-lg-6">
<h3>Firste caption</h3>
<p>Loren ipsun</p>
</div>
</div>
<div class="carousel-item ">
<div class="col-lg-6">
<img src="http://lorempixel.com/400/200/" alt="Los Angeles" width="400" height="200">
</div>
<div class="col-lg-6">
<h3>Firste caption</h3>
<p>Loren ipsun</p>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
将.row
放在.carousel-item
内,将.col-*
放在.row
内。像这样:
...
<div class="carousel-item ">
<div class="row">
<div class="col-lg-6">
<img src="http://lorempixel.com/400/200/" alt="Los Angeles" width="400" height="200">
</div>
<div class="col-lg-6">
<h3>Firste caption</h3>
<p>Loren ipsun</p>
</div>
</div>
</div>
...
如果您希望轮播以较低的宽度保持分割,您可能希望将col-lg-6
与col-md-6
,col-sm-6
或col-6
交换(在v4中表示它将在所有宽度上保持分裂。)
以下是一个例子:
.carousel-item {
background-color: #424242;
color: white;
min-height: 220px;
}
&#13;
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet"/>
<div id="carouselExample" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<div class="row">
<div class="col-6">
<img class="d-block w-100" src="http://lorempixel.com/304/220/" alt="First slide">
</div>
<div class="col-6 d-flex align-items-center">
<div>
<h2>Title</h2>
<p>Lorem ipsum</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="row">
<div class="col-6">
<img class="d-block w-100" src="http://lorempixel.com/304/220/nightlife/" alt="Second slide">
</div>
<div class="col-6 d-flex align-items-center">
<div>
<h2>Title</h2>
<p>Lorem ipsum</p>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="row">
<div class="col-6">
<img class="d-block w-100" src="http://lorempixel.com/304/220/sports/" alt="Third slide">
</div>
<div class="col-6 d-flex align-items-center">
<div>
<h2>Title</h2>
<p>Lorem ipsum</p>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExample" 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="#carouselExample" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
&#13;