Hover 和 JS 动画/交互在 `` 元素上无法正常工作。

huangapple go评论59阅读模式
英文:

Hover and JS animation/interaction isn't working with <a> element

问题

以下是翻译的代码部分:

let slideIndex = 1
showSlides(slideIndex)

function plusSlides(n) {
  showSlides(slideIndex += n)
}

function currentSlide(n) {
  showSlides(slideIndex = n)
}

function showSlides(n) {
  let i;
  let slides = document.getElementsByClassName('mySlides')
  let 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'
  slides[slideIndex - 1].className += " active"
}
#top {
  position: relative;
  z-index: -100;
  width: 100%;
}

.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;
  z-index: 100;
}

.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

#top a:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

.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 {
  animation-name: fade;
  animation-duration: 1.5s;
}

@keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: .1
  }
}
<!DOCTYPE html>
<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="style.css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css2?family=Bevan&display=swap" rel="stylesheet">
</head>

<body>
  <div id="page">
    <div class="toggle-btn" onclick="toggleFunction()">
      <span></span>
      <span></span>
      <span></span>
    </div>
    <nav id="header">
      <img src="pantherlogo.png" alt="Panthers Logo" id="logo">
      <div id="navbar">
        <h3><a href="index.html">HOME</a></h3>
        <h3><a href="news.html">NEWS</a></h3>
        <h3><a href="team.html">TEAMS</a></h3>
        <h3><a href="contacts.html">CONTACTS</a></h3>
      </div>
    </nav>
    <div id="top">
      <div class="mySlides fade">
        <img src="https://placehold.co/600x400" alt="football" id="footballimg">
        <div id="motto">
          <h1>Restore the pride.</h1>
        </div>
      </div>
      <div class="mySlides fade">
        <img src="https://placehold.co/600x400" alt="football" id="footballimg">
      </div>
      <div class="mySlides fade">
        <img src="https://placehold.co/600x400" alt="football" id="footballimg">
      </div>
      <div class="mySlides fade">
        <img src="https://placehold.co/600x400" alt="football" id="footballimg">
      </div>
      <a class="prev" onclick="plusSides(-1)">&#10094;</a>
      <a class="next" onclick="plusSides(1)">&#10095;</a>
    </div>
    <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>
      <span class="dot" onclick="currentSlide(4)"></span>
    </div>
  </div>
  <!-- 其他内容 -->
</body>

</html>

这是您提供的代码的翻译。如果需要进一步的帮助,请随时告诉我。

英文:

I'm creating a website for a football team and want a sliding image slideshow. The dots on the bottom of the slideshow, but for whatever reason I can't interact with the arrow buttons (&lt;a&gt;).

Whenever I hover or try to click on the arrows (.prev or .next) nothing happens.

It is supposed to have a shadow/background on hover, and on click it is supposed to move to the next img in the slide show.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

let slideIndex = 1
showSlides(slideIndex)
function plusSlides(n) {
showSlides(slideIndex += n)
}
function currentSlide(n) {
showSlides(slideIndex = n)
}
function showSlides(n) {
let i;
let slides = document.getElementsByClassName(&#39;mySlides&#39;)
let dots = document.getElementsByClassName(&#39;dot&#39;)
if (n &gt; slides.length) {
slideIndex = 1
}
if (n &lt; 1) {
slideIndex = slides.length
}
for (i = 0; i &lt; slides.length; i++) {
slides[i].style.display = &#39;none&#39;
}
for (i = 0; i &lt; dots.length; i++) {
dots[i].className = dots[i].className.replace(&#39; active&#39;, &#39;&#39;)
}
slides[slideIndex - 1].style.display = &#39;block&#39;
slides[slideIndex - 1].className += &quot; active&quot;
}

<!-- language: lang-css -->

#top {
position: relative;
z-index: -100;
width: 100%;
}
.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;
z-index: 100;
}
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
#top a:hover {
background-color: rgba(0, 0, 0, 0.8);
}
.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 {
animation-name: fade;
animation-duration: 1.5s;
}
@keyframes fade {
from {
opacity: .4
}
to {
opacity: .1
}
}

<!-- language: lang-html -->

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
&lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot;&gt;
&lt;link href=&quot;https://fonts.googleapis.com/css2?family=Bevan&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;page&quot;&gt;
&lt;!--&lt;div id=&quot;topnav&quot;&gt;
&lt;div id=&quot;modal&quot;&gt;
&lt;span class=&quot;close&quot;&gt;&amp;times;&lt;/span&gt;
&lt;div id=&quot;modaltext&quot;&gt;
&lt;h1&gt;Home of the Panthers.&lt;/h1&gt;
&lt;h2&gt;Pride. Tradition. Commitment.&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;--&gt;
&lt;div class=&quot;toggle-btn&quot; onclick=&quot;toggleFunction()&quot;&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;nav id=&quot;header&quot;&gt;
&lt;img src=&quot;pantherlogo.png&quot; alt=&quot;Panthers Logo&quot; id=&quot;logo&quot;&gt;
&lt;div id=&quot;navbar&quot;&gt;
&lt;h3&gt;&lt;a href=&quot;index.html&quot;&gt;HOME&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=&quot;news.html&quot;&gt;NEWS&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=&quot;team.html&quot;&gt;TEAMS&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=&quot;contacts.html&quot;&gt;CONTACTS&lt;/a&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;/nav&gt;
&lt;div id=&quot;top&quot;&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;div id=&quot;motto&quot;&gt;
&lt;h1&gt;Restore the pride.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;/div&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;/div&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;/div&gt;
&lt;a class=&quot;prev&quot; onclick=&quot;plusSides(-1)&quot;&gt;&amp;#10094;&lt;/a&gt;
&lt;a class=&quot;next&quot; onclick=&quot;plusSides(1)&quot;&gt;&amp;#10095;&lt;/a&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: center&quot;&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(1)&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(2)&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(3)&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(4)&quot;&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;main&quot;&gt;
&lt;div class=&quot;slide-up&quot;&gt;
&lt;div class=&quot;container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Home of the Panthers&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;text-container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Pride.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;text-container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Tradition.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;text-container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Commitment.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;
&lt;div id=&quot;map&quot; class=&quot;footercontent&quot;&gt;
&lt;h3&gt;Sitemap&lt;/h3&gt;
&lt;h4&gt;&lt;a href=&quot;index.html&quot;&gt;Home&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;a href=&quot;news.html&quot;&gt;News&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;a href=&quot;team.html&quot;&gt;Teams&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;a href=&quot;contacts.html&quot;&gt;Contacts&lt;/a&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div id=&quot;contactus&quot; class=&quot;footercontent&quot;&gt;
&lt;h3&gt;Contact Us&lt;/h3&gt;
&lt;h4&gt;Email&lt;/h4&gt;
&lt;h4&gt;Twitter&lt;/h4&gt;
&lt;h4&gt;Instagram&lt;/h4&gt;
&lt;h4&gt;Facebook&lt;/h4&gt;
&lt;/div&gt;
&lt;div id=&quot;copyright&quot;&gt;
&lt;h5&gt;Copyright&lt;/h5&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;imageslide.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

<!-- end snippet -->

答案1

得分: 0

It looks like you have a typo error "plusSlides(-1)".

英文:

It looks like you have a typo error "plusSlides(-1)".

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
&lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot;&gt;
&lt;link href=&quot;https://fonts.googleapis.com/css2?family=Bevan&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;page&quot;&gt;
&lt;!--&lt;div id=&quot;topnav&quot;&gt;
&lt;div id=&quot;modal&quot;&gt;
&lt;span class=&quot;close&quot;&gt;&amp;times;&lt;/span&gt;
&lt;div id=&quot;modaltext&quot;&gt;
&lt;h1&gt;Home of the Panthers.&lt;/h1&gt;
&lt;h2&gt;Pride. Tradition. Commitment.&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;--&gt;
&lt;div class=&quot;toggle-btn&quot; onclick=&quot;toggleFunction()&quot;&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;nav id=&quot;header&quot;&gt;
&lt;img src=&quot;pantherlogo.png&quot; alt=&quot;Panthers Logo&quot; id=&quot;logo&quot;&gt;
&lt;div id=&quot;navbar&quot;&gt;
&lt;h3&gt;&lt;a href=&quot;index.html&quot;&gt;HOME&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=&quot;news.html&quot;&gt;NEWS&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=&quot;team.html&quot;&gt;TEAMS&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=&quot;contacts.html&quot;&gt;CONTACTS&lt;/a&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;/nav&gt;
&lt;div id=&quot;top&quot;&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;div id=&quot;motto&quot;&gt;
&lt;h1&gt;Restore the pride.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;/div&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;/div&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;/div&gt;
&lt;a class=&quot;prev&quot; onclick=&quot;plusSlides(-1)&quot;&gt;&amp;#10094;&lt;/a&gt;
&lt;a class=&quot;next&quot; onclick=&quot;plusSlides(1)&quot;&gt;&amp;#10095;&lt;/a&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: center&quot;&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(1)&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(2)&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(3)&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(4)&quot;&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;main&quot;&gt;
&lt;div class=&quot;slide-up&quot;&gt;
&lt;div class=&quot;container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Home of the Panthers&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;text-container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Pride.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;text-container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Tradition.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;text-container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Commitment.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;
&lt;div id=&quot;map&quot; class=&quot;footercontent&quot;&gt;
&lt;h3&gt;Sitemap&lt;/h3&gt;
&lt;h4&gt;&lt;a href=&quot;index.html&quot;&gt;Home&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;a href=&quot;news.html&quot;&gt;News&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;a href=&quot;team.html&quot;&gt;Teams&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;a href=&quot;contacts.html&quot;&gt;Contacts&lt;/a&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div id=&quot;contactus&quot; class=&quot;footercontent&quot;&gt;
&lt;h3&gt;Contact Us&lt;/h3&gt;
&lt;h4&gt;Email&lt;/h4&gt;
&lt;h4&gt;Twitter&lt;/h4&gt;
&lt;h4&gt;Instagram&lt;/h4&gt;
&lt;h4&gt;Facebook&lt;/h4&gt;
&lt;/div&gt;
&lt;div id=&quot;copyright&quot;&gt;
&lt;h5&gt;Copyright&lt;/h5&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;imageslide.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

<!-- end snippet -->

答案2

得分: 0

要修复问题,请移除负的 z-index 值 -100,并将拼写错误的 plusSides 改正为 plusSlides

这是一个示例代码:

let slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
  showSlides(slideIndex += n);
}

function currentSlide(n) {
  showSlides(slideIndex = n);
}

function showSlides(n) {
  let i;
  let slides = document.getElementsByClassName('mySlides');
  let 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';
  slides[slideIndex - 1].className += " active";
}
#top {
  position: relative;
  width: 100%;
}

.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;
  z-index: 100;
}

.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

#top a:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

.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 {
  animation-name: fade;
  animation-duration: 1.5s;
}

@keyframes fade {
  from {
    opacity: .4;
  }
  to {
    opacity: .1;
  }
}
<!DOCTYPE html>
<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="style.css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css2?family=Bevan&display=swap" rel="stylesheet">
</head>

<body>
  <div id="page">
    <!-- Your HTML content here -->
  </div>
  <script src="script.js"></script>
  <script src="imageslide.js"></script>
</body>

</html>
英文:

To fix the issue, remove the negative z-index of -100 and correct the typo plusSides to plusSlides.

Here is a sample code:

<!-- begin snippet: js hide: false console: true babel: null -->

<!-- language: lang-js -->

let slideIndex = 1
showSlides(slideIndex)
function plusSlides(n) {
showSlides(slideIndex += n)
}
function currentSlide(n) {
showSlides(slideIndex = n)
}
function showSlides(n) {
let i;
let slides = document.getElementsByClassName(&#39;mySlides&#39;)
let dots = document.getElementsByClassName(&#39;dot&#39;)
if (n &gt; slides.length) {
slideIndex = 1
}
if (n &lt; 1) {
slideIndex = slides.length
}
for (i = 0; i &lt; slides.length; i++) {
slides[i].style.display = &#39;none&#39;
}
for (i = 0; i &lt; dots.length; i++) {
dots[i].className = dots[i].className.replace(&#39; active&#39;, &#39;&#39;)
}
slides[slideIndex - 1].style.display = &#39;block&#39;
slides[slideIndex - 1].className += &quot; active&quot;
}

<!-- language: lang-css -->

#top {
position: relative;
width: 100%;
}
.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;
z-index: 100;
}
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
#top a:hover {
background-color: rgba(0, 0, 0, 0.8);
}
.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 {
animation-name: fade;
animation-duration: 1.5s;
}
@keyframes fade {
from {
opacity: .4
}
to {
opacity: .1
}
}

<!-- language: lang-html -->

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
&lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot;&gt;
&lt;link href=&quot;https://fonts.googleapis.com/css2?family=Bevan&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;page&quot;&gt;
&lt;!--&lt;div id=&quot;topnav&quot;&gt;
&lt;div id=&quot;modal&quot;&gt;
&lt;span class=&quot;close&quot;&gt;&amp;times;&lt;/span&gt;
&lt;div id=&quot;modaltext&quot;&gt;
&lt;h1&gt;Home of the Panthers.&lt;/h1&gt;
&lt;h2&gt;Pride. Tradition. Commitment.&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;--&gt;
&lt;div class=&quot;toggle-btn&quot; onclick=&quot;toggleFunction()&quot;&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;nav id=&quot;header&quot;&gt;
&lt;img src=&quot;pantherlogo.png&quot; alt=&quot;Panthers Logo&quot; id=&quot;logo&quot;&gt;
&lt;div id=&quot;navbar&quot;&gt;
&lt;h3&gt;&lt;a href=&quot;index.html&quot;&gt;HOME&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=&quot;news.html&quot;&gt;NEWS&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=&quot;team.html&quot;&gt;TEAMS&lt;/a&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;a href=&quot;contacts.html&quot;&gt;CONTACTS&lt;/a&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;/nav&gt;
&lt;div id=&quot;top&quot;&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;div id=&quot;motto&quot;&gt;
&lt;h1&gt;Restore the pride.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;/div&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;/div&gt;
&lt;div class=&quot;mySlides fade&quot;&gt;
&lt;img src=&quot;https://placehold.co/600x400&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;&gt;&lt;!--img src=&quot;footballimg.png&quot; alt=&quot;football&quot; id=&quot;footballimg&quot;--&gt;
&lt;/div&gt;
&lt;a class=&quot;prev&quot; onclick=&quot;plusSlides(-1)&quot;&gt;&amp;#10094;&lt;/a&gt;
&lt;a class=&quot;next&quot; onclick=&quot;plusSlides(1)&quot;&gt;&amp;#10095;&lt;/a&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: center&quot;&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(1)&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(2)&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(3)&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;dot&quot; onclick=&quot;currentSlide(4)&quot;&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;main&quot;&gt;
&lt;div class=&quot;slide-up&quot;&gt;
&lt;div class=&quot;container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Home of the Panthers&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;text-container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Pride.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;text-container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Tradition.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;text-container reveal&quot;&gt;
&lt;div class=&quot;text-box&quot;&gt;
&lt;h1&gt;Commitment.&lt;/h1&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;
&lt;div id=&quot;map&quot; class=&quot;footercontent&quot;&gt;
&lt;h3&gt;Sitemap&lt;/h3&gt;
&lt;h4&gt;&lt;a href=&quot;index.html&quot;&gt;Home&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;a href=&quot;news.html&quot;&gt;News&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;a href=&quot;team.html&quot;&gt;Teams&lt;/a&gt;&lt;/h4&gt;
&lt;h4&gt;&lt;a href=&quot;contacts.html&quot;&gt;Contacts&lt;/a&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div id=&quot;contactus&quot; class=&quot;footercontent&quot;&gt;
&lt;h3&gt;Contact Us&lt;/h3&gt;
&lt;h4&gt;Email&lt;/h4&gt;
&lt;h4&gt;Twitter&lt;/h4&gt;
&lt;h4&gt;Instagram&lt;/h4&gt;
&lt;h4&gt;Facebook&lt;/h4&gt;
&lt;/div&gt;
&lt;div id=&quot;copyright&quot;&gt;
&lt;h5&gt;Copyright&lt;/h5&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;imageslide.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年4月11日 10:07:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75981932.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定