title: CSS Slideshow not showing image until clicked
body: <p>So I've been trying to implement the slideshow that is on the W3Schools website for a while now.
  (<a href="https://www.w3schools.com/howto/howto_js_slideshow.asp" rel="nofollow noreferrer">https://www.w3schools.com/howto/howto_js_slideshow.asp</a>)</p>
  
  <p>I've gotten it to work but the first image is not loading. Only when I click on the left/right buttons or the radio buttons does the image show.</p>
  
  <p>I'll attach a screen shot of what I mean.
  <a href="https://i.stack.imgur.com/klATL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/klATL.png" alt="before clicking the buttons"></a>
  <a href="https://i.stack.imgur.com/hUy6c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hUy6c.png" alt="after clicking"></a></p>
  
  <p>I thought this might be an issue with having the display:none; but surely changing this means that you get all of the images loading at the same time.</p>
  
  <p>EDIT: Code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>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 &gt; slides.length) {
      slideIndex = 1
    }
    if (n &lt; 1) {
      slideIndex = slides.length
    }
    for (i = 0; i &lt; slides.length; i++) {
      slides[i].style.display = "none";
    }
    for (i = 0; i &lt; dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
    }
    slides[slideIndex - 1].style.display = "block";
    dots[slideIndex - 1].className += " active";
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.dealshead section {
    padding-left: 200px;
    float: right;
    position: relative;
    padding-top: 0;
    margin-top: 0;
  }
  
  * {
    box-sizing: border-box
  }
  
  
  /* Slideshow container */
  
  .slideshow-container {
    max-height: 300px;
    max-width: 300px;
    margin-top: 0;
  }
  
  .mySlides {
    display: none;
  }
  
  
  /* Next &amp; previous buttons */
  
  .prev,
  .next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    margin-top: -45px;
    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);
  }
  
  
  /* 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
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section&gt;
    &lt;img class="mySlides fade" src="images\whiteonblack.jpg" style="width:100%"&gt;
    &lt;img class="mySlides fade" src="images\blackonwhite.jpg" style="width:100%"&gt;
    &lt;img class="mySlides fade" src="images\yellowonred.jpg" style="width:100%"&gt;
    &lt;a class="prev" onclick="plusSlides(-1)"&gt;&amp;#10094;&lt;/a&gt;
    &lt;a class="next" onclick="plusSlides(1)"&gt;&amp;#10095;&lt;/a&gt;
    &lt;div style="text-align:center"&gt;
      &lt;span class="dot" onclick="currentSlide(1)"&gt;&lt;/span&gt;
      &lt;span class="dot" onclick="currentSlide(2)"&gt;&lt;/span&gt;
      &lt;span class="dot" onclick="currentSlide(3)"&gt;&lt;/span&gt;
    &lt;/div&gt;
  &lt;/section&gt;</code></pre>
  </div>
  </div>
  </p>