如何在 JavaScript 或 CSS 中制作文本动画效果、Hello World 到 HW?
第一个文本是Hello World!最后,成为HW,其他字母消失。
你好世界!
↓
地狱世界!
↓
他太棒了!
↓
硬件
<script>
export default {
name:"Introduction",
data() {
return {
timer:1,
}
},
mounted() {
this.deathLoop = null
this.deathLoop = setInterval(()=>{
this.timer+=1
if(this.timer>4) this.timer=1
},1000)
},
}
</script>
<style scoped>
.Introduction{
padding-top: 60px;
height: 100%;
width: 100%;
color: #333;
font-size: 20px;
}
span{
font-size: 30px;
height: 20px;
line-height: 20px;
margin-top: 10px;
}
</style>
<template>
<div class="Introduction">
<span >H</span>
<span v-show="timer<4">e</span>
<span v-show="timer<3">l</span>
<span v-show="timer<3">l</span>
<span v-show="timer<2">o</span>
<span> </span>
<span >W</span>
<span v-show="timer<3">o</span>
<span v-show="timer<3">r</span>
<span v-show="timer<4">l</span>
<span v-show="timer<4">d</span>
<span v-show="timer<4">!</span>
</div>
</template>
检查图像。也许这就是你想要的。Vue.js2 的代码,你可以用纯 Javascript 复制它
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句