Since this is one rather long question-thank in advance to those who bother to read it! I am doing a personal blog website project, and in the index page, I want to achieve a slideshow header (contains a background picture, a title and a button redirecting user to the actual psot) to display featured blog posts dynamically. I also wanted fade-in effect when the header transform into another one. My html for the header looks like this:
var slideIndex = 0;
function carousel() {
var i;
var x = document.getElementsByClassName("header-slide");
for (i = 0; i < x.length; i++) {
x[i].style.opacity = 0;
x[i].style.display = "none";
}
slideIndex++;
if (slideIndex > x.length) {
slideIndex = 1;
}
x[slideIndex - 1].style.opacity = 1;
x[slideIndex - 1].style.display = "block";
setTimeout(carousel, 3000);
}
.header-1 {
background-image: linear-gradient(rgba(0, 0, 0, 0.29), #000), url(background-image#1);
background-size: cover;
background-position: center;
background-attachment: fixed;
height: 100vh;
}
.header-2 {
background-image: linear-gradient(rgba(0, 0, 0, 0.29), #000), url(background-image#2);
background-size: cover;
background-position: center;
background-attachment: fixed;
height: 100vh;
}
.header-3 {
background-image: linear-gradient(rgba(0, 0, 0, 0.29), #000), url(background-image#3);
background-size: cover;
background-position: center;
background-attachment: fixed;
height: 100vh;
}
.header-style {
display: none;
transition: opacity .5s ease-in;
}
<div class="slideshow-container">
<div class="header-slide">
<header class="header-1">
<nav>
<div class="row">
<ul class="main-nav">
<li><a href="article_directory.html">Articles</a></li>
<li><a href="http://collegiatecycling.org/accc/">Collegiate Racing</a></li>
<li><a href="photo_gallery.html">Multimedia</a></li>
<li><a href="current_projects.html">Current Porjects</a></li>
<li><a href="get_in_touch.php">Get in touch</a></li>
<li><a href="#first-footer-child">External</a></li>
</ul>
</div>
</nav>
<div class="hero-text-box">
<h1>Article#1</h1>
<a class="btn btn-full" href="#">Read full story</a>
</div>
</header>
</div>
<div class="header-slide">
<header class="header-2">
<nav>
<div class="row">
<ul class="main-nav">
<li><a href="article_directory.html">Articles</a></li>
<li><a href="http://collegiatecycling.org/accc/">Collegiate Racing</a></li>
<li><a href="photo_gallery.html">Multimedia</a></li>
<li><a href="current_projects.html">Current Porjects</a></li>
<li><a href="get_in_touch.php">Get in touch</a></li>
<li><a href="#first-footer-child">External</a></li>
</ul>
</div>
</nav>
<div class="hero-text-box">
<h1>Article#2</h1>
<a class="btn btn-full" href="#">Read more</a>
</div>
</header>
</div>
<div class="header-slide">
<header class="header-3">
<nav>
<div class="row">
<ul class="main-nav">
<li><a href="article_directory.html">Articles</a></li>
<li><a href="http://collegiatecycling.org/accc/">Collegiate Racing</a></li>
<li><a href="photo_gallery.html">Multimedia</a></li>
<li><a href="current_projects.html">Current Porjects</a></li>
<li><a href="get_in_touch.php">Get in touch</a></li>
<li><a href="#first-footer-child">External</a></li>
</ul>
</div>
</nav>
<div class="hero-text-box">
<h1>Article#3</h1>
<a class="btn btn-full" href="#">Read more</a>
</div>
</header>
</div>
</div>
I already have the following js script, which, while embedded in the html file, does slideshow the header, but fails to achieve a fade-in effect.
I want the fade-in effect as well, so I added the following CSS codes.
With all the above measures, my website header still fails to slideshow in with fade-in effect. My question is, it seems setting the transition property doesn't change anything, as the header opacity is changed by my js script (so every time it changes from 0 to 1, the CSS would handle how it changes)? Any assistance appreciated!