gpt4 book ai didi

javascript - Bootstrap 轮播宽度和高度

转载 作者:IT王子 更新时间:2023-10-29 03:10:54 31 4
gpt4 key购买 nike

我正在尝试为图像做一个全宽(宽度:100%)和固定高度的 Bootstrap 轮播,但是如果我将宽度设置为 100%,高度也会自动采用 100%

我不确定问题是否在我的文件中

 <div id="myCarousel" class="carousel slide">
<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>
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active item">
<%= image_tag "slider/slide-bg-1.jpg", class: "tales" %>
</div>
<div class="item">
<%= image_tag "slider/slide-bg-2.jpg", class: "tales" %>
</div>
<div class="item">
<%= image_tag "slider/slide-bg-3.jpg", class: "tales" %>
</div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>

和我的CSS文件

.tales {
width: 100%;
height: 200px;
}

最佳答案

你想让它响应吗?如果您是,那么我只推荐以下内容:

.tales {
width: 100%;
}
.carousel-inner{
width:100%;
max-height: 200px !important;
}

但是,响应式处理此问题的最佳方法是使用如下媒体查询:

/* Smaller than standard 960 (devices and browsers) */
@media only screen and (max-width: 959px) {}

/* Tablet Portrait size to standard 960 (devices and browsers) */
@media only screen and (min-width: 768px) and (max-width: 959px) {}

/* All Mobile Sizes (devices and browser) */
@media only screen and (max-width: 767px) {}

/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
@media only screen and (min-width: 480px) and (max-width: 767px) {}

/* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */
@media only screen and (max-width: 479px) {}

关于javascript - Bootstrap 轮播宽度和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19481334/

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