gpt4 book ai didi

css - 试图让 Bootstrap 轮播按比例调整大小

转载 作者:行者123 更新时间:2023-11-28 17:08:43 26 4
gpt4 key购买 nike

我试图让 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 -->

最佳答案

您是否以正确的顺序加载 .js 文件?

我按此顺序加载了它们....并且您的代码运行完美。

  1. bootstrap.min.css
  2. jquery-2.1.3.min.js
  3. bootstrap.min.js

关于css - 试图让 Bootstrap 轮播按比例调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29726556/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com