JSFiddle - React, Tailwind, and code Playground
by LW
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/typed.js/1.1.1/typed.min.js"></script>
<div class="wrap">
<div class="banner">
<h1>We Are <span class="typed"></span></h1>
</div>
<p>here some text..</p>
</div>
CSS
body {
background: #333;
color: #fff;
margin: 0;
padding: 0;
text-align:center;
}
.banner {
display: block;
width: 400px;
margin:0 auto;
position: relative;
transition:0.75s;
}
h1{font-size:40px;}
/*Add custom cursor so it auto inherits font styles*/
.typed::after {
content: '|';
display: inline;
-webkit-animation: blink 0.7s infinite;
-moz-animation: blink 0.7s infinite;
animation: blink 0.7s infinite;
}
/*Removes cursor that comes with typed.js*/
.typed-cursor{
opacity: 0;
display: none;
}
/*Custom cursor animation*/
@keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
@-webkit-keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
@-moz-keyframes blink{
0% { opacity:1; }
50% { opacity:0; }
100% { opacity:1; }
}
JavaScript
$(function(){
$(".typed").typed({
strings: ["Developers gqre wgwrg rgrwtg regw rewg rw grtw egwretgerw gwe y ey.", "Designers.", "People."],
// Optionally use an HTML element to grab strings from (must wrap each string in a <p>)
stringsElement: null,
// typing speed
typeSpeed: 30,
// time before typing starts
startDelay: 1200,
// backspacing speed
backSpeed: 20,
// time before backspacing
backDelay: 500,
// loop
loop: true,
// false = infinite
loopCount: 5,
// show cursor
showCursor: false,
// character for cursor
cursorChar: "|",
// attribute to type (null == text)
attr: null,
// either html or text
contentType: 'html',
// call when done callback function
callback: function() {},
// starting callback function before each string
preStringTyped: function() {},
//callback for every typed string
onStringTyped: function() {},
// callback for reset
resetCallback: function() {}
});
});