css - 我的幻灯片上的图像不会显示
问题描述
我的图片不会出现在我的幻灯片中。
我已经直接从 w3school 复制并粘贴了 html 和 css 的幻灯片代码,它适用于我以前的项目,但不适用于我当前的项目。我不认为,我在我的 html 中做错了什么,因为在我编写 css 代码之前,图像就在那里。此外,如果我删除代码显示:没有图像再次出现,但它到处都是。
请帮助这个可怜的学生在 tmr 提交他的作业!
这是我对 html5 和 css 的编码
.slide {
width: 30%;
margin: auto;
}
.mySlides {
display: none;
}
.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;
}
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
.prev:hover, .next:hover {
background-color: #ec7979;
}
.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 {
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;
}
.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}
}
<section id="screens" class="odd">
<h1 id="clear">App Screens</h1>
<div class="slide">
<!-- 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="img/store.png" style="width:100%">
<div class="text">store page</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="img/home.png" style="width:100%">
<div class="text">home page</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="img3.jpg" style="width:100%">
<div class="text">Caption Three</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>
</div>
<p>'My wedding' is an online platform where people share<br> ideas and experiences about their wedding.</p>
</section>
解决方案
Can you share w3 school slider link where you got code for slider.
<script>
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
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";
}
</script>
推荐阅读
- node.js - Mongoose.connect 通过异步尝试等待捕获错误 nodejs 然后连接到 mongo 数据库
- java - 一对一关系映射 JPA SpringBoot 实现报错:必须在调用 save() 之前手动分配此类的 id
- python - 我正在寻找有关如何正确处理 Ctrl+C 退出代码时返回的异常的建议。我是 Python/prgming 的新手。运行win10
- graph - 拓扑排序解决方案验证
- java - 在 Eclipse IDE 中使用 org.apache.commons.collections 的 ClassNotFoundException 问题
- javascript - TypeScript HTML 按钮“文件不包含在任何 tsconfig.json 中” Intellij
- google-analytics - 谷歌分析中每个用户 ID 的页面访问和持续时间
- angular - 发生未处理的异常:ENOENT: 没有这样的文件或目录,lstat 'E\CoffeShop\node_modules' 有关详细信息,请参阅“C:\aangular-errors.log”
- javascript - 如果在同一日期,则隐藏元素,并且仅使用 ngIf 显示一次
- powershell - 如何让 Powershell 的 Import-Csv 正确导入空格