[英]Why are the slideshow pictures bigger than the screen (and container)?
之前的问题都解决了,非常感谢大家的帮助。 但现在出现了新的。 问题是当我删除所有容器的大小(之前是 1024 像素)时,我的幻灯片图像变得比屏幕大得多。 请参阅图像1 [和] 2 。 请帮助我需要在主页上显示全尺寸幻灯片图像而无需向下滚动。 HTML
<!--Start Home-->
<section class="home" id="home">
<div class="container">
<div class="mySlides">
<img src="img/Home/вид1 классика.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="img/Home/спальня море1.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="img/Home/07.jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="img/Portfolio/4/розовая комната (5).jpg" style="width:100%">
</div>
<div class="mySlides">
<img src="img/Portfolio/3/титова мал спальня (3).jpg" style="width:100%">
</div>
</div>
</section>
<!--End Home-->
主页部分的 CSS
/*Home Section*/
.home {
height: 100vh;
background-size: cover;
background-position: center;
}
.home .container {
height: 850px;
}
.home .container .mySlides {
padding-top: 70px;
width: 100%;
}
整个网站的CSS(查看主要元素的特性)
html {
scroll-behavior: smooth;
}
body {
margin: 0;
font-family: 'Montserrat', sans-serif;
max-width: 100%;
}
*{
box-sizing: border-box;
margin: 0;
padding: 0;
}
.container {
margin: auto;
}
.row {
display: flex;
flex-wrap: wrap;
}
.section-title {
flex: 0 0 100%;
max-width: 100%;
margin-bottom: 40px;
}
.section-title h1 {
display: inline-block;
font-size: 30px;
text-transform: uppercase;
font-weight: 500;
margin: 0 0 10px;
position: relative;
}
.text-center {
text-align: center!important;
}
.text-left {
text-align: left!important;
}
.text-right {
text-align: right!important;
}
JS
// Automatic Slideshow - change image every 5 seconds
var myIndex = 0;
carousel();
function carousel() {
var i;
var x = document.getElementsByClassName("mySlides");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
myIndex++;
if (myIndex > x.length) {myIndex = 1}
x[myIndex-1].style.display = "block";
setTimeout(carousel, 5000);
}
在 devtools 中写道,section 和 container 的高度为 850,但带有幻灯片的 div 更大。 不知道为什么。 见3
预先感谢您的帮助。
mySlides
div 没有height
值,所以它需要他的内容的高度,即使它确实有height
你也有溢出问题。 我建议给 img 本身的height
值或max-height
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.