Skip to content

Instantly share code, notes, and snippets.

@notoriousb1t
Created February 26, 2018 20:06
Show Gist options
  • Save notoriousb1t/c4b195a44724adb96cbc32491ca74f46 to your computer and use it in GitHub Desktop.
Save notoriousb1t/c4b195a44724adb96cbc32491ca74f46 to your computer and use it in GitHub Desktop.
Split Rainbow
<div class="rainbow">RAINBOW</div>
Splitting.chars('.rainbow')
<script src="https://unpkg.com/[email protected]/splitting.js"></script>
html, body, .rainbow {
height: 100%;
overflow: hidden;
font-family: PT Sans;
}
body {
background-color: #111;
}
.rainbow .word {
--ratio: calc(1 / var(--char-total));
font-size: calc(100vw * var(--ratio));
}
.rainbow .char {
--color: calc(var(--char-index) * 360 / var(--char-total));
--duration: 3600ms;
background-color: hsl(var(--color), 60%, 65%);
border: solid thin black;
color: hsl(calc(var(--color)), 50%, 20%);
flex: 0 0 inherit;
width: calc(100% * var(--ratio));
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
animation-name: flip;
animation-duration: 4800ms;
animation-timing-function: cubic-bezier(0.5, 0, 0.5, 1);
animation-delay: calc(160ms * var(--char-index));
animation-iteration-count: infinite;
animation-fill-mode: both;
}
.splitting > .word {
display: flex;
justify-content: space-evenly;
align-items: center;
width: 100%;
height: 100%;
text-align: center;
}
@keyframes flip {
0%, 10% {
transform: scale(1) rotateY(0turn);
}
40%, 60% {
transform: scale(.75) rotateY(0.5turn);
}
90%, 100% {
transform: scale(1) rotateY(1turn);
}
}
<link href="https://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment