Guest User

Untitled

a guest
Oct 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. document.addEventListener('DOMContentLoaded',function(event){
  2. // array with texts to type in typewriter
  3. var dataText = [ "Hi, I'm Ned.", "Developer.", "Writer."];
  4.  
  5. function typeWriter(i) {
  6. // add next character to h1
  7. document.querySelector("h1").innerHTML = dataText[i] +'<span aria-hidden="true"></span>';
  8.  
  9. // wait for a while and call this function again for next character
  10. setTimeout(function() {
  11. typeWriter((i + 1)%2)
  12. }, 10000);
  13. }
  14.  
  15. // start the text animation
  16. typeWriter(0);
  17. });
  18.  
  19. .typewriter h1 {
  20. font-weight: bold;
  21. color: #fefff7;
  22. font-family: "Lucida Console";
  23. font-size: 7em;
  24. overflow: hidden; /*Hide content before animation*/
  25. border-right: .1em solid white; /*Cursor*/
  26. white-space: nowrap; /*Keep text on same line*/
  27. margin: 0 auto; /*Scrolling effect while typing*/
  28. letter-spacing: .1em;
  29. animation:
  30. typing 3s steps(30, end),
  31. blink-caret .75s steps(1, end) infinite alternate;
  32. }
  33.  
  34. /* The typing effect */
  35. @keyframes typing {
  36. from {
  37. width: 0
  38. }
  39. to {
  40. width: 100%
  41. }
  42. }
  43.  
  44. /* The typewriter cursor effect */
  45. @keyframes blink-caret {
  46. from, to {
  47. border-color: transparent
  48. } 50% {
  49. border-color: white;
  50. }
  51. }
  52.  
  53. <div class="jumbotron" id="jumbotron">
  54. <div class="typewriter">
  55. <h1></h1>
  56. </div>
  57. </div>
Add Comment
Please, Sign In to add comment