Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thiagolopes-dev/097a4c6470c96a3ca63d4d111243dea4 to your computer and use it in GitHub Desktop.
Save thiagolopes-dev/097a4c6470c96a3ca63d4d111243dea4 to your computer and use it in GitHub Desktop.

Revisions

  1. thiagolopes-dev created this gist May 5, 2020.
    7 changes: 7 additions & 0 deletions efeito-maquina-de-escrever-com-javascript.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    Efeito Máquina de Escrever com JavaScript
    -----------------------------------------


    A [Pen](https://codepen.io/ReneSena/pen/VdXpXO) by [Rene Sena](https://codepen.io/ReneSena) on [CodePen](https://codepen.io).

    [License](https://codepen.io/ReneSena/pen/VdXpXO/license).
    11 changes: 11 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <html lang="pt-br">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Efeito Máquina de Escrever</title>
    <link rel="stylesheet" href="css/styles.css">
    </head>
    <body class="container">
    <h1 class="titulo-principal">Efeito Máquina de Escrever com JavaScript, utilize em seus projetos esse efeito bacana!</h1>
    </body>
    </html>
    13 changes: 13 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    function typeWrite(elemento){
    const textoArray = elemento.innerHTML.split('');
    elemento.innerHTML = ' ';
    textoArray.forEach(function(letra, i){

    setTimeout(function(){
    elemento.innerHTML += letra;
    }, 75 * i)

    });
    }
    const titulo = document.querySelector('.titulo-principal');
    typeWrite(titulo);
    26 changes: 26 additions & 0 deletions style.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    .container{
    background-color: #000;
    }
    .titulo-principal{
    max-width: 480px;
    text-align: center;
    margin: 60px auto;
    font-family:'Courier New', Courier, monospace;
    color: #fff;
    }
    .titulo-principal:after{
    content: '|';
    margin-left: 5px;
    opacity: 1;
    animation: pisca .7s infinite;
    }
    /* Animação aplicada ao content referente a classe *.titulo-principal* resultando num efeito de cursor piscando. */

    @keyframes pisca{
    0%, 100%{
    opacity: 1;
    }
    50%{
    opacity: 0;
    }
    }