JSFiddle - React, Tailwind, and code Playground
by Nick Hulea
HTML
<button id="makeItRainbow" class="btn">
<span class="txt anim-text-flow-hover">Make It Rainbow</span>
</button>
<button id="makeItRain" class="btn">
<span class="txt anim-text-flow-hover">Make It Rain</span>
</button>
SCSS
body {
overflow: hidden;
margin: 0px;
width: 100vw;
height: 100vh;
background: -webkit-gradient(linear, left top, left bottom, from(#ef31f9), to(rgba(125, 185, 232, 0)));
background: linear-gradient(180deg, #ef31f9, rgba(125, 185, 232, 0));
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ef31f9", endColorstr="#007db9e8", GradientType=0)
}
#app {
position: relative
}
#app,
body,
html {
height: 100vh;
width: 100vw;
-webkit-box-sizing: border-box;
box-sizing: border-box
}
body,
html {
padding: 0;
margin: 0;
overflow: hidden
}
#sketch[data-v-923376ae] {
/* background: -webkit-gradient(linear, left top, left bottom, from(#ef31f9), to(rgba(125, 185, 232, 0))); */
background: linear-gradient(180deg, #ef31f9, rgba(125, 185, 232, 0));
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ef31f9", endColorstr="#007db9e8", GradientType=0)
}
.btn {
position: fixed;
top: 0;
margin: 1rem;
-webkit-appearance: none;
border: none;
outline: none;
padding: 10px 20px;
cursor: pointer;
background: none;
color: #fff;
font-weight: 900;
text-transform: uppercase;
}
#makeItRain {
right: 0;
}
#makeItRainbow {
left: 0;
}
.rainbow-text {
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.00, red), color-stop(16%, orange), color-stop(32%, yellow), color-stop(48%, green), color-stop(60%, blue), color-stop(76%, indigo), color-stop(1.00, violet));
}
/*
* Animation module with all animation code
*/
.anim-text-flow,
.anim-text-flow-hover:hover {
/*
* Animation variables
*/
$animationSteps: 250;
$animationDuration: 10;
$animationElement: span;
$animationElementsCount: 100;
$delayBetweenLetters: 0.1;
/*
* Elements settings
*/
#{$animationElement} {
animation-name: anim-text-flow-keys;
animation-duration: #{$animationDuration}s;
...
JavaScript
$('.txt').html(function(i, html) {
var chars = $.trim(html).split("");
return '<span>' + chars.join('</span><span>') + '</span>';
});