微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

twitter-bootstrap – 如何在Bootstrap – Carousel中将图像缩放到全高?

我试图在Bootstrap Carousel控件中显示一个应该填满整个屏幕的图像.我正在使用1024px * 795px的图像

我正在使用Bootstrap站点上给出的全尺寸图像示例.水平方向,它可以很好地填满屏幕.但垂直方向不能很好地扩展.我应该添加/删除哪些属性,以便图像填满整个屏幕,尽管它们的像素大小较小?

我怎么能在响应式设计中做到这一点,以便图像可以扩展到任何尺寸?

我在示例网站上使用css,只在carousel.html中更改CSS.

解决方法

我意识到这个答案有点晚了,但我也遇到了与Bootstrap旋转木马相似的挑战.为了使100%的高度起作用,转盘及其任何’父容器也必须是100%高度.

我在Bootstrap CSS类中添加了一些覆盖:

html,body{height:100%;}
.carousel,.item,.active{height:100%;}
.carousel-inner{height:100%;}
.fill{width:100%;height:100%;background-position:center;background-size:cover;}

然后相应地将“填充”类添加到您的轮播:

<div class="container fill">
<div id="myCarousel" class="carousel slide">
  <div class="carousel-inner">
    <div class="active item">
      <div class="fill" style="background-image:url('//www.portalapp.com/images/greengrass.jpg');">
        <div class="container">
          <h1 class="pull-left pull-middle light-color"><strong><a href="#">Slide 1</a></strong></h1>

        </div>
      </div>
    </div>
    <div class="item">
      <div class="fill" style="background-image:url('//placehold.it/1024x700');">
        <div class="container">
          <h1 class="pull-left pull-middle light-color"><strong><a href="#">Slide 2</a></strong></h1>

        </div>
      </div>
    </div>
  </div>
  <div class="pull-center">
    <a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
    <a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
  </div>
</div>
</div>

这是一个工作示例:http://bootply.com/59900

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐