我正在尝试在我的网站中创建幻灯片,但图像未显示。出现幻灯片的按钮和箭头,但不出现图像。
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="app.css">
<meta charset="utf-8">
</head>
<body>
</div>
<!-- Slideshow container -->
<div class="slideshow-container">
<!-- Full-width images with number and caption text -->
<div class="mySlides">
<div class="numbertext">1 / 3</div>
<img src="etat.jpg">
<div class="text">Les aides</div>
</div>
<div class="mySlides">
<div class="numbertext">2 / 3</div>
<img src="tips.jpeg">
<div class="text">Les Tips</div>
</div>
<div class="mySlides">
<div class="numbertext">3 / 3</div>
<img src="bonsplans.jpg">
<div class="text">Les bons plans</div>
</div>
<!-- Next and previous buttons -->
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</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>
</body>
</html>
/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
/* Hide the images by default */
.mySlides {
display: none;
}
/* 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;
user-select: none;
}
/* 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 {
animation-name: fade;
animation-duration: 1.5s;
}
@keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
我使用了 W3schools 的代码。它并不打算成为自动幻灯片,因此我没有包含 JavaScript。我想要的结果是一个简单的轮播,就像 W3schools 网站上展示的那样。
我确实验证了图像的名称和 html 标签的名称,以检查它们是否正确。不知道其余部分的 CSS 代码是否会干扰幻灯片。
尝试将所有图像添加到单独的文件夹中并在项目中使用它们并确保路径正确, 例如,如果您有一个公共文件夹,并且里面有资产文件夹,其中包含所有图像,则像
一样导入它们