twitter-bootstrap – 如何在Bootstrap – Carousel中将图像缩放
发布时间:2020-12-18 00:18:08 所属栏目:安全 来源:网络整理
导读:我试图在Bootstrap Carousel控件中显示一个应该填满整个屏幕的图像.我正在使用1024px * 795px的图像 我正在使用Bootstrap站点上给出的全尺寸图像示例.水平方向,它可以很好地填满屏幕.但垂直方向不能很好地扩展.我应该添加/删除哪些属性,以便图像填满整个屏幕
我试图在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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |