I found the following code:
var index = 0;
var text = 'Hardcode';
// Here you can put in the text you want to make it type.
function type()
{
document.getElementById('intro1').innerHTML += text.charAt(index);
index += 1;
var t = setTimeout('type()',200);
// The time taken for each character here is 100ms. You can change it if you want.
}
The problem is that the text only applies to a few attributes in my CSS (marked with //):
#intro1 {
font-family: 'Press Start 2P', cursive; //OK
font-size: 80px; //OK
display: block; //?
text-align: center; //OK
margin-bottom: auto;
margin-top: auto;
top: 50%;
}
I'm trying to get the text appear to the center of the page, but JavaScript ignores my placing.
It worked when I typed the text directly in to the div
in HTML, but when I made JavaScript do the dirty work, it messed it up.
Also, how can I add an delay to the animation (starts after interval)?
Help, please?