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

前端之家收集整理的这篇文章主要介绍了twitter-bootstrap – 如何在Bootstrap – Carousel中将图像缩放到全高?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在Bootstrap Carousel控件中显示一个应该填满整个屏幕的图像.我正在使用1024px * 795px的图像

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

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

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

解决方法

@H_403_11@ 我意识到这个答案有点晚了,但我也遇到了与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

原文链接:https://www.f2er.com/bootstrap/234139.html

猜你在找的Bootstrap相关文章