当屏幕尺寸缩小时,我试图让Bootstrap 3旋转木马按比例缩小 - 即我希望它保持相同的形状,因为它变得更小。开箱即用它只是缩小(缩小,但不是更短)。我得到了我想要的图像,但旋转木马的背景并没有跟随。我尝试了各种各样的事情,但无法弄清楚。任何提示都将不胜感激。谢谢!
不幸的是我还没有在这里发布图片。基本上,当它的大小缩小时,旋转木马的灰色背景从图像下面突出。
/* CUSTOMIZE THE CAROUSEL
-------------------------------------------------- */
/* Carousel base class */
.carousel {
max-height: 500;
max-width: 753px;
width: auto;
height: auto;
margin-left: auto;
margin-right: auto;
margin-bottom: 60px;
margin-top: 50px;
}
/* Since positioning the image, we need to help out the caption */
/*.carousel-caption {
z-index: 10;
}*/
/* Declare heights because of positioning of img element */
.carousel .item {
width: 100%;
height: 500px;
min-height: 100px;
background-color: #777;
}
.carousel-inner > .item > img {
position: absolute;
top: 0;
left: 0;
min-width: 100%;
width: auto;
height: auto;
}

<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="first-slide" src="img/htff-1.jpg" alt="First slide">
<div class="container">
<!-- <div class="carousel-caption">
<h1>Example headline.</h1>
<p>Note: If you're viewing this page via a <code>file://</code> URL, the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.</p>
</div> -->
</div>
</div>
<div class="item">
<img class="second-slide" src="img/lostDivision-025.JPG" alt="Second slide">
<div class="container">
<!-- <div class="carousel-caption">
<h1>Another example headline.</h1>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Learn more</a></p>
</div> -->
</div>
</div>
<div class="item">
<img class="third-slide" src="img/sballard_01.jpg" alt="Third slide">
<div class="container">
<!-- <div class="carousel-caption">
<h1>One more for good measure.</h1>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<p><a class="btn btn-lg btn-primary" href="#" role="button">Browse gallery</a></p>
</div> -->
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div><!-- /.carousel -->
&#13;
答案 0 :(得分:1)
您是否按正确的顺序加载.js文件?
我按照这个顺序加载它们......你的代码运行得很好。
答案 1 :(得分:0)
尝试将height:100%
添加到您的上一个选择器。这将使您的容器保持其形状,同时在浏览器大小更改时仍然调整大小。