Bootstrap滑块图像在响应视图中拉伸

时间:2015-09-08 10:05:03

标签: css3 bootstrap-slider

是否有针对响应式视图的bootstrap滑块图像拉伸问题的解决方案?我不想设置身高默认

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

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

Slider Responsive View - Image Getting Stretched

1 个答案:

答案 0 :(得分: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上查看。