Created
February 11, 2022 23:05
-
-
Save benbartling/796e3527f1b3609702099a9b600ff97c to your computer and use it in GitHub Desktop.
Vue Word Rotation Component w/ TailwindCSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<span class="word-wrapper"> | |
<span class="filler">---</span> | |
<span class="word" v-for="(word, index) in words" :key="index"> | |
{{ word }} | |
</span> | |
</span> | |
</template> | |
<script> | |
export default { | |
props: ["words"] | |
}; | |
</script> | |
<style lang="sass"> | |
.word-wrapper | |
@apply inline-block text-left relative text-red-600 | |
.filler | |
@apply opacity-0 | |
.word | |
@apply opacity-0 absolute inset-0 | |
animation: topToBottom 10s linear infinite 0s | |
&:nth-child(2) | |
animation-delay: 2.5s | |
&:nth-child(3) | |
animation-delay: 5s | |
&:nth-child(4) | |
animation-delay: 7.5s | |
@keyframes topToBottom | |
0% | |
opacity: 0 | |
5% | |
opacity: 0 | |
transform: translateY(-100%) | |
10% | |
opacity: 1 | |
transform: translateY(0px) | |
25% | |
opacity: 1 | |
transform: translateY(0px) | |
30% | |
opacity: 0 | |
transform: translateY(100%) | |
80% | |
opacity: 0 | |
100% | |
opacity: 0 | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment