如何在轮播中对齐图像中心

时间:2018-11-12 16:37:52

标签: bootstrap-4

我从引导程序首页复制了此代码,并做了一些改动。我尝试了多种方法来对齐图像中心,但是没有用。我已经搜索了与此问题相关的问题,但是找不到合适的答案。我也尝试使用外部CSS样式和内部CSS样式,但是效果不佳。我应该怎么做才能解决此问题?

<!doctype html>
<html lang="en">
  <head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>Carousel</title>
</head>
<body>
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
  <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
  <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
  <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
  <div class="carousel-item active center">
    <img class="center-block" src="karshi_train.jpg" alt="First slide" style="width:70%">
    <div class="carousel-caption d-none d-md-block">
      <h5>On the train</h5>
      <p>Afrosiayb, the express train in Uzbekistan runs up to 200km per hour.</p>
    </div>
  </div>
  <div class="carousel-item">
    <img class="center-block" src="mudbrick.jpg" alt="Second slide" style="width:70%">
    <div class="carousel-caption d-none d-md-block">
      <h5>In the countryside</h5>
      <p>They still make a brick with mud. They build their house with it. </p>
    </div>
  </div>
  <div class="carousel-item">
    <img class="center-block" src="toshak.jpg" alt="Third slide" style="width:70%">
    <div class="carousel-caption d-none d-md-block">
      <h5>In a room</h5>
      <p>Everybody has toshak in their room.</p>
    </div>
  </div>
</div>

<a class="carousel-control-prev" href="#carouselExampleIndicators" 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="#carouselExampleIndicators" role="button" data-slide="next">
  <span class="carousel-control-next-icon" aria-hidden="true"></span>
  <span class="sr-only">Next</span>
</a>
</div>

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
 </body>
 </html>

0 个答案:

没有答案