gpt4 book ai didi

html - 轮播不适合移动设备的屏幕

转载 作者:行者123 更新时间:2023-12-04 10:10:16 25 4
gpt4 key购买 nike

我的网站上有一个旋转木马,它不适合移动屏幕,图像移动到屏幕分辨率之外。当我检查浏览器中的响应能力时,它会正确显示。

下面是它如何在移动屏幕上显示的图像

image

当我在浏览器中检查响应性时,它显示如下

image2

这是我的代码

<div id="demo" class="carousel slide" data-ride="carousel">
<!-- <ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1"></li>
<li data-target="#demo" data-slide-to="2"></li>
</ul> -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="images\home_banners\banner1.png" alt="top international schools in bangalore">
</div>
<div class="carousel-item">
<img src="images\home_banners\banner2.png" alt="best cbse schools in bangalore south">
<div class="carousel-caption">
</div>
</div>
<div class="carousel-item">
<img src="images\home_banners\banner3.png" alt="schools in bangalore icse">
<div class="carousel-caption">
</div>
</div>
<div class="carousel-item">
<img src="images\home_banners\banner4.png" alt="best cbse schools in bangalore south">
<div class="carousel-caption">
</div>
</div>
<div class="carousel-item">
<img src="images\home_banners\banner5.png" alt="schools in bangalore icse">
<div class="carousel-caption">
</div>
</div>
</div>
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>

这是 CSS我有
#demo {
top: 95px;
}

.carousel-inner img {
/*width: auto !important;*/
height: auto;
width: 100% !important;
/*height: 100%; */
/* height: 500px; */
}

最佳答案

使用 img-fluid您的类(class) img标签。

#demo {
top: 95px;
}

.carousel-inner img {
/*width: auto !important;*/
height: auto;
width: 100% !important;
/*height: 100%; */
/* height: 500px; */
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">

<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>

<div id="demo" class="carousel slide" data-ride="carousel">
<!-- <ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1"></li>
<li data-target="#demo" data-slide-to="2"></li>
</ul> -->
<div class="carousel-inner">
<div class="carousel-item active">
<img class="img-fluid" src="https://via.placeholder.com/150?text=1" alt="top international schools in bangalore">
</div>
<div class="carousel-item">
<img class="img-fluid" src="https://via.placeholder.com/150?text=2" alt="best cbse schools in bangalore south">
<div class="carousel-caption">
</div>
</div>
<div class="carousel-item">
<img class="img-fluid" src="https://via.placeholder.com/150?text=3" alt="schools in bangalore icse">
<div class="carousel-caption">
</div>
</div>
<div class="carousel-item">
<img class="img-fluid" src="https://via.placeholder.com/150?text=4" alt="best cbse schools in bangalore south">
<div class="carousel-caption">
</div>
</div>
<div class="carousel-item">
<img class="img-fluid" src="https://via.placeholder.com/150?text=5" alt="schools in bangalore icse">
<div class="carousel-caption">
</div>
</div>
</div>
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>

关于html - 轮播不适合移动设备的屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61363146/

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