|
代码:
<style>
#ma {
margin: 20px auto;
width: 600px;
height: 200px;
font: bold 2.4em sans-serif;
color: transparent;
overflow: hidden;
display: flex;
justify-content: center;
align-items: end;
}
.txtBox {
text-shadow: 0 0 0 rgba(0,0,0,1);
animation: gone var(--du) var(--de) infinite;
}
@keyframes gone {
40% {
text-shadow: 0 0 0 rgba(0,0,0,.6);
opacity: .5;
}
100% {
text-shadow: 0 0 0 rgba(0,0,0,.3);
transform: translate(-20px,-60px) rotate(-180deg) skew(20deg) scale(1.8);
opacity: 0;
}
}
</style>
<div id="ma"></div>
<script>
let strAr = '烟消云散一杯谁共歌欢'.split('');
strAr.forEach((text,key) => {
let span = document.createElement('span');
span.className = 'txtBox';
span.textContent = text;
span.style.cssText += `
--du: ${strAr.length * .8 + 1}s;
--de: ${key * .8}s;
`;
ma.appendChild(span);
});
</script>
|