如何在Carousel中设置图像的大小:

时间:2017-03-28 11:22:43

标签: html css carousel

我一直在尝试将图像的大小设置为相同的值。我需要所有图像以相同的尺寸(相同的高度和宽度)出现。以下是Carousel的代码。所有图像均以原始尺寸显示。我该如何实现这一目标?

    <div id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
      <li data-target="#myCarousel" data-slide-to="1"></li>
      <li data-target="#myCarousel" data-slide-to="2"></li>
      <li data-target="#myCarousel" data-slide-to="3"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
      <div class="item active">
        <img src="images\banner.jpg"   alt="Chania">
      </div>

      <div class="item">
        <img src="images\banner_1.jpg" alt="Chania" >
      </div>

      <div class="item">
        <img src="images\banner_2.png" alt="Flower">
      </div>

      <div class="item">
        <img src="images\banner_3.jpg" alt="Flower">
      </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>

我使用的CSS代码是:

<style>
  .carousel-inner > .item > img,
  .carousel-inner > .item > a > img {
      width:   70%;
      height:  40%;   
      margin: auto;
  }
  </style>

0 个答案:

没有答案