<h1>Easily timed changes with random durations.</h1>
<section>
<div class="emoji">😊</div>
<div class="emoji">😊</div>
<div class="emoji">😊</div>
<div class="emoji">😊</div>
<div class="emoji">😊</div>
</section>
@import url('https://fonts.googleapis.com/css2?family=Nunito&family=Signika+Negative:wght@400;600&display=swap');
body {
background-color: #fff;
color: black;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
font-family: "Signika Negative", sans-serif, Arial;
margin: 1rem;
min-height: 100vh;
overflow: hidden;
z-index: -1;
}
h1 {
font-weight: 400;
font-size: 1.8rem;
}
section {
position: relative;
flex: 0 0 auto;
width: 600px;
border: solid 3px white;
padding: 1rem;
}
section:after {
content: "";
position: absolute;
top: 0;
left: 50%;
width: 2px;
background-color: #313639;
height: 100%;
z-index: -1;
}
section:after {
content: "";
position: absolute;
top: 0;
left: 50%;
height: 100%;
border-left: 3px solid white;
}
.emoji {
margin: 6px 0;
width: 40px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
font-size: 40px;
will-change: transform;
z-index: 2;
}
gsap.registerPlugin(TextPlugin);
gsap.utils.toArray(".emoji").forEach(element => {
gsap.timeline({ repeat: -1, yoyo: true })
.to(element, {
x: 500,
xPercent: 100,
transformOrigin: 'center',
ease: "none",
duration: "random(2, 5)"
})
.set(element, {
text: "🥳",
}, "<50%");
});
This Pen doesn't use any external CSS resources.