I know that this question has been asked many times before:
Javascript: Fade In images on page load; one after the other?
Fade in divs one after another
jQuery .fadeIn() on page load?
But I've tried all of the suggested techniques and none of them worked. I'm trying to get three lines of text (the words are wrapped in divs), to appear one after the other when the page loads. Here is what I have:
HTML:
<div class="row"><!--second row-->
<div class="col-lg-12 center">
<div id="tagline-wrapper">
<div class="center-text hidden1">Responsive</div>
<div class="between-lines">
<div class="line"></div>
<div class="clean hidden2">Clean</div>
<div class="line"></div>
</div>
<div class="center-text hidden3">Powerful</div>
</div>
</div>
</div><!--end row-->
CSS:
.center {
text-align: center;
display: flex;
color: #ffffff;
font-family: 'proxima_nova_ltsemibold';
text-transform: uppercase;
font-size: 52px;
}
#tagline-wrapper {
margin-top: 150px;
margin-left: auto;
margin-right: auto;
}
.center-text {
text-align: center;
font-family: 'proxima_nova_ltsemibold';
font-size: 52px;
text-transform: uppercase;
color: #ffffff;
}
.between-lines {
display: flex;
align-items: center;
}
.line {
border-bottom: 2px solid #ffffff;
display: block;
flex-grow: 1;
height: 0;
}
.clean {
padding: 0 1.5rem;
text-align: center;
font-family: 'proxima_nova_ltsemibold';
font-size: 52px;
text-transform: uppercase;
color: #ffffff;
}
/*hide elements initially*/
.hidden1 {
display: none;
}
.hidden2 {
display: none;
}
.hidden3 {
display: none;
}
JavaScript
$(document).ready(function(){
var elements = [ 'hidden1, hidden2, hidden3' ];
for (var i = 0; i < elements.length; i++) {
setTimeout(function() {
elements[i].style.opacity = 1;
}, 1250 * i);
}
});
The above is the JS technique that was suggested in the first linked article.
JSFiddle attempt with the first technique here: https://jsfiddle.net/b184reyv/1/
JSFiddle attempt with the second technique here: https://jsfiddle.net/b184reyv/2/
JSFiddle attempt with the third technique here: https://jsfiddle.net/4w7kxLxf/
Thank you.