<p class="line-1 anim-typewriter">Hi! I'm Brittany.</p>
<h1>
<a href="" class="typewrite" data-period="1000" data-type='[ "I am a Software Developer.","I love to code.", "I build web applications.", "Follow me on Twitter or Dev.to." ]'>
<span class="wrap"></span>
</a>
</h1>
@import url(https://fonts.googleapis.com/css?family=Anonymous+Pro);
body {
background-color: white;
font-family: 'Anonymous Pro', monospace;
text-align: center;
color: black;
padding-top:10em;
}
* { color:black; text-decoration: none; font-family: 'Anonymous Pro', monospace;}
.line-1{
position: relative;
top: 50%;
width: 24em;
margin: 0 auto;
border-right: 2px solid rgba(255,255,255,.75);
font-size: 180%;
text-align: center;
white-space: nowrap;
overflow: hidden;
transform: translateY(-50%);
}
/* Animation */
.anim-typewriter{
animation: typewriter steps(44) 1s 1 normal both,
blinkTextCursor 500ms steps(44) normal;
}
@keyframes typewriter{
from{width: 0;}
to{width: 9.3em;}
}
var TxtType = function(el, toRotate, period) {
this.toRotate = toRotate;
this.el = el;
this.loopNum = 0;
this.period = parseInt(period, 10) || 1000;
this.txt = '';
this.tick();
this.isDeleting = false;
};
TxtType.prototype.tick = function() {
var i = this.loopNum % this.toRotate.length;
var fullTxt = this.toRotate[i];
if (this.isDeleting) {
this.txt = fullTxt.substring(0, this.txt.length - 1);
} else {
this.txt = fullTxt.substring(0, this.txt.length + 1);
}
this.el.innerHTML = '<span class="wrap">'+this.txt+'</span>';
var that = this;
var delta = 200 - Math.random() * 100;
if (this.isDeleting) { delta /= 2; }
if (!this.isDeleting && this.txt === fullTxt) {
delta = this.period;
this.isDeleting = true;
} else if (this.isDeleting && this.txt === '') {
this.isDeleting = false;
this.loopNum++;
delta = 500;
}
setTimeout(function() {
that.tick();
}, delta);
};
window.onload = function() {
var elements = document.getElementsByClassName('typewrite');
for (var i=0; i<elements.length; i++) {
var toRotate = elements[i].getAttribute('data-type');
var period = elements[i].getAttribute('data-period');
if (toRotate) {
new TxtType(elements[i], JSON.parse(toRotate), period);
}
}
// INJECT CSS
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = ".typewrite > .wrap { border-right: 0.08em solid black; font-family: 'Anonymous Pro', monospace;}";
document.body.appendChild(css);
};
This Pen doesn't use any external CSS resources.