0

有没有针对响应式视图的引导滑块图像拉伸问题的解决方案?我不想设置高度默认值

http://getbootstrap.com/examples/carousel/

我尝试使用上面的滑块,这是 twitter bootstrap 中给出的默认滑块。当我在该滑块中包含图像时,它正在拉伸。如果有人遇到此问题,请告诉我解决方案

滑块响应视图 - 图像被拉伸

4

1 回答 1

1

我不确定你是否已经在寻找这个,但 Bootstrap 还提供了一个用于响应式图像的类。刚刚将它添加到 img-tag 中。

HTML

<div class="slider">
  <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
      <li data-target="#carousel-example-generic" data-slide-to="1"></li>
      <li data-target="#carousel-example-generic" data-slide-to="2"></li>
    </ol>
    <!-- Wrapper for slides -->
    <div class="carousel-inner">
      <div class="item active">
        <img src="http://dreamatico.com/data_images/cat/cat-6.jpg"  class="img-responsive" alt="Slider 1">
        <div class="carousel-caption">
        <h3>Caption Text</h3>
      </div>
   </div>
   <div class="item">
     <img src="http://dreamatico.com/data_images/cat/cat-6.jpg"  class="img-responsive" alt="Slider 2">
     <div class="carousel-caption">
       <h3>Caption Text</h3>
     </div>
   </div>
  <div class="item">
    <img src="http://dreamatico.com/data_images/cat/cat-6.jpg"  class="img-responsive" alt="Slider 3">
    <div class="carousel-caption">
      <h3>Caption Text</h3>
    </div>
  </div>
  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
  </a>
  </div> <!-- Carousel -->
</div>

JavaScript

$('.carousel').carousel({
    interval: 3000
})

jsfiddle上也可以看到它。

于 2015-09-08T12:17:48.793 回答