gpt4 book ai didi

javascript - 内容未出现在我的图片幻灯片下方

转载 作者:行者123 更新时间:2023-11-30 13:47:37 25 4
gpt4 key购买 nike

在 w3schools 和其他一些资源的帮助下,我设法编写了一个响应式图像 slider ,但是我无法在图像幻灯片下方显示任何内容。它只是没有出现。您可以在代码中看到填充段落。那没有出现。我试过没有内容 div 类和有。我知道这不是段落本身,因为它在其他页面上完全可以正常工作。

<div class="slideshow-container">

<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="img1/img1.jpg" style="width:100%">
<div class="text">Caption Text</div>
</div>

<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="img1/img2.jpg" style="width:100%">
<div class="text">Caption Two</div>
</div>

<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="img1/img3.jpg" style="width:100%">
<div class="text">Caption Three</div>
</div>

</div>
<br>

<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>

<script>
var slideIndex = 0;
showSlides();

function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
setTimeout(showSlides, 9000); // Change image every 2 seconds
}
</script>
<div class="header">
<h1>yeet</h1>
<p>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>

和CSS

* {box-sizing: border-box;}
body {font-family: Verdana, sans-serif;}
.mySlides {display: none;}
img {vertical-align: middle;}

.slideshow-container {
position: relative;
height: 0;
margin: auto;
width: 100%;
-webkit-backface-visibility: hidden;
-webkit-transform: scale(1);
}


.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}


.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}

.dot {
-webkit-backface-visibility: hidden;
-webkit-transform: scale(1);
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 9.6s ease;
}

.active {
-webkit-backface-visibility: hidden;
-webkit-transform: scale(1);
background-color: #717171;
}

.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}

@-webkit-keyframes slide {
100% { left: 0; }
}

@keyframes slide {
100% { left: 0; }
}

@media only screen and (max-width: 300px) {
.text {font-size: 11px}
}

最佳答案

幻灯片容器的高度是0。
里面的图片有自己的高度,覆盖下面的文字。如果从 .slide-container 中删除 height: 0;,该段落将显示。

.slideshow-container {
height: 0; /* <-- Remove this line */
}

关于javascript - 内容未出现在我的图片幻灯片下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58973908/

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