JSFiddle - React, Tailwind, and code Playground
by luka kupunia
HTML
<div class="box">
<div class="center">
<h1><span>Luka</span></h1>
<h2><span>Kupunia</span></h2>
<div id="text" data-text="Front-End Developer">
</div>
</div>
<div class="white"></div>
</div>
CSS
@import url('https://fonts.googleapis.com/css?family=M+PLUS+Rounded+1c:400,700&display=swap');
body {
margin: 0;
background: #0212EF;
background: black;
}
* {
box-sizing: border-box;
font-family: 'M PLUS Rounded 1c', sans-serif;
}
div.box {
position: relative;
}
h1 {
margin: 0;
font-size: 60px;
color: white;
/* line-height: 70px; */
overflow: hidden;
}
h1 span {
display: inline-block;
transform: translateY(100%);
backface-visibility: hidden;
transition: cubic-bezier(0.02, 0.01, 0.06, 1) 1s 0.5s;
}
body.active h1 span {
transform: translateY(0%);
}
div.white {
width: 70%;
height: 150px;
position: absolute;
right: 0;
bottom: 0;
background: white;
transform: scaleX(0);
transition: cubic-bezier(0.02, 0.01, 0.06, 1) 1s 1.2s;
transform-origin: right;
}
body.active div.white{
transform: scaleX(1)
}
h2 {
margin: 0;
font-size: 60px;
color: white;
/* line-height: 70px; */
overflow: hidden;
}
h2 span {
display: inline-block;
transform: translateY(100%);
backface-visibility: hidden;
transition: cubic-bezier(0.02, 0.01, 0.06, 1) 1s 0.7s;
}
body.active h2 span {
transform: translateY(0);
}
div.box {
position: absolute;
left: 50%;
top: 0;
right: 0;
bottom: 0;
transform: scaleX(0);
transition: cubic-bezier(0.02, 0.01, 0.06, 1) 1s;
transform-origin: right;
border: 10px solid black;
border-radius: 0 30px 30px 0;
background: #0212EF;
}
body.active div.box {
transform: scaleX(1);
}
div.center {
position: absolute;
top:50%;
left: 50%;
transform: translate(-50%,-50%);
max-width: 100%;
}
div#text {
font-size: 30px;
font-weight: 700;
height: 45px;
width: 320px;
}
JavaScript
setTimeout(function(){
document.querySelector('body').classList.add('active')
},500)
var kfn_type = function(element,speed){
var text = element.dataset.text;
var arr = Array.from(text);
var b = 0;
var int = setInterval(function(){
if (b === arr.length - 1) {
clearInterval(int)
}
element.innerHTML += arr[b];
b++;
},speed)
}
setTimeout(function() {
kfn_type(document.querySelector('#text'),30)
}, 1700);