JavaScriptでスライドショーの画像が表示されません。
サンプルのコードを参考にしたのですが、上手くスライドショーが実装できません。それ以前に、画像が表示されません。よろしくお願いいたします。
var slideIndex = 1;
showSlides(slideIndex);
//ボタンのコントロール
function plusSlides(n){
showSlides(slideIndex += n);
}
//画像のコントロール
function showSlides(n){
var i;
var slides = document.getElementsByClassName("mySlides");
var slides = 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<DOMStringList.length; i++){
dots[i].className = dots[i],className.replace("avtive", "")
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += "active";
}
{
box-sizing: border-box;
}
body {
color: white;
text-align: center;
font-size: 0.8rem;
background: url('file:///Users/owner/Downloads/Canva%20-%20Photo%20of%20Flowers%20on%20Bucket.jpg') fixed;
background-size: cover;
}
.header {
padding: 170px 30 px 80px;
height: 100vh;
}
.bg-mask {
background: rgba(255, 255, 255, 0.5);
width: 60%;
margin: 0 auto;
padding-top: 10;
}
.site-title-sub {
margin: 200px 30px 0px 30px;
padding-top: 10px;
letter-spacing: 1px;
font-size: 2rem;
color: #330000;
font-family: "DM Serif Display", cursive;
}
.site-title {
margin: 50px;
font-size: 8rem;
color: #330000;
font-family: "DM Serif Display", cursive;
}
.site-description {
margin-bottom: 50px;
color: #FF0461;
font-size: 3rem;
font-family: "DM Serif Display", cursive;
}
/*検索フォーム*/
.form1 {
position: relative;
max-width: 300px;
margin-bottom: 20px;
}
.sbox1 {
height: 50px;
padding: 0 10px;
position: absolute;
left: 0;
top: 0;
border-radius: 25px;
outline: 0;
background: #eee;
}
.subtn1 {
height: 50px;
width: 50px;
position: absolute;
left: 250px;
top: 0;
background:#7fbfff;
color: #fff;
border: none;
border-radius: 0 25px 25px 0;
}
.sbtn1 .fa-search {
font-size: 20px;
position: absolute;
top: 30%;
left: 30%;
}
.sbtn1 :hover {
color: #888;
}
/*コンテンツ*/
.contents {
height: 100vh;
margin: 0 50px;
background-color: white;
position: relative;
}
.heading1 {
display: inline-block;
margin: 30px 0 15px;
padding-bottom: 15px;
letter-spacing: 2px;
color: #330000;
font-size: 4rem;
font-family: "DM Serif Display", cursive;
}
/*スライドショー*/
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
.mySlides {
display: none;
}
/*ボタン*/
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
color: #330000;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
/*次へボタンを右の位置にする*/
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/*ボタンを透かせる*/
.prev:hover, .next:hover {
background-color: rgba(0, 0, 0, 0.8)
}
/*番号*/
.numbertext {
color: #330000;
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}
}
/*コンタクト*/
.footer {
height: 100vh;
padding: 80px 0 150px;
}
.heading2 {
display: inline-block;
margin: 30px 0 15px;
padding-bottom: 15px;
letter-spacing: 2px;
font-size: 4rem;
font-family: "DM Serif Display", cursive;
}
.contact-form {
width: 50%;
margin: 50px auto 0;
}
.contact-form input[type=text], .contact-form textarea {
display: block;
width: 100%;
margin-bottom: 10px;
padding: 15px;
outline: none;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 0;
color: #333;
}
.contact-form textarea {
height: 150px;
}
.contact-form input[type=submit] {
display: block;
width: 200px;
margin: 40px auto 0;
padding: 15px;
border: 1px solid rgba(255,255, 255);
border-radius: 5px;
color: #333;
cursor: pointer;
}
<!DOCTYPE html>
<hrml>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="UTF-8">
<title>LoF</title>
<mata name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="kadai.css">
<link type="text/html" href="https://fonts.google.com/specimen/DM+Serif+Display">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js"></script>
<script type="text/javascript" src="kadai.js"></script>
<!--[if lt IR 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</script>
</head>
<body>
<header class="header">
<div class="bg-mask">
<p class="site-title-sub">----- Language of Flowers -----</p>
<h1 class="site-title">LoF</h1>
<p class="site-description">Find your happiness.</p>
<form id="form1" action="#" method="get">
<input id="sbox1" id="search" name="search" type="text" placeholder="Flower name"/>
<button id="sbtn1" type="submit"><i class="fas fa-search"></i>
</button>
</form>
</div>
</header>
<div class="contents">
<h2 class="heading1">Seasonal Flowers</h2>
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext">1/3</div>
<img src="file:///Users/owner/Downloads/Canva%20-%20null.jpg" width="600" height="400">
<div class="text">Hibiscus</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2/3</div>
<img src="file:///Users/owner/Downloads/Canva%20-%20Close-up%20Photo%20Of%20Sunflower.jpg" width="600" height="400">
<div class="text">Sunflower</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3/3</div>
<img src="file:///Users/owner/Downloads/Canva%20-%20null%20(1).jpg" width="600" height="400">
<div class="content">Cosmos</div>
</div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
<br>
<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>
<div class="footer">
<h2 class="heading2">Contact</h2>
<form class="contact-form">
<input type="text" name="name" placeholder="NAME">
<textarea name="message" placeholder="MESSAGE"></textarea>
<input type="submit" value="SEND">
</form>
</div>
</div>
</body>
</hrml>