gpt4 book ai didi

html 幻灯片无法正确显示图像

转载 作者:行者123 更新时间:2023-11-28 02:07:10 24 4
gpt4 key购买 nike

我是一名 11 年级的 IT 学生,我正在努力将图片幻灯片添加到我正在处理的网站上,我尝试查找解决方案,但似乎无法找到解决我问题的任何方法.

当我在 chrome 中运行网页时,一切似乎都在那里,但图像不包含在幻灯片容器中,它们沿着页面向下移动。

恐怕这可能是一个非常简单的解决方案,因为我仍在学习,但如果有人能够找出问题所在,我将不胜感激,因为这很快就要到期,而且我已经没有其他选择了。我从 w3schools 获得了代码。

下面是我的html文档中的代码:

<!-- Slideshow container -->
<div class="slideshow-container">

<!-- Full-width images with number and caption text -->
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="images/max_photos.jpg" style="width:100%"/>
<div class="text">Caption Text</div>
</div>

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

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

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

<!-- Next and previous buttons -->
<a class="prev" onclick="plusSlides(-1)">&#10094;</a>
<a class="next" onclick="plusSlides(1)">&#10095;</a>
</div>
<br>

<!-- The dots/circles -->
<div style="text-align:center">
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>

CSS 代码:

* {box-sizing:border-box}

/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}

/* Hide the images by default */
.mySlides {
display: together;
}

/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
}

/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}

/* On hover, add a black background color with a little bit see-through
*/
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}

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

/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}

/* The dots/bullets/indicators */
.dot {
cursor:pointer;
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}

.active, .dot:hover {
background-color: #717171;
}

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

@-webkit-keyframes fade {
from {opacity: .4}
to {opacity: 1}
}

@keyframes fade {
from {opacity: .4}
to {opacity: 1}
}

我以前从未在这个网站上发过帖子,我希望我已经包括了所有需要的东西。

最佳答案

您是否为此幻灯片添加了任何 JavaScript?我猜不会。可能您想关注 w3school。您需要使用 JavaScript 代码来一次显示一张图片并隐藏其他图片
对于您编写的相同代码,您有一个现成的示例,请点击链接: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_slideshow

关于html 幻灯片无法正确显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48961322/

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