<div class="box"></div>
<button>Restart</button>
.box {
width: 200px;
height: 200px;
background-color: lightgreen;
margin-bottom: 10px;
}
// fromTo approach
document.querySelector("button").addEventListener("click", () => gsap.fromTo(".box", {opacity: 0}, {opacity: 1}));
// Control method approach
// const anim = gsap.from(".box", {opacity: 0});
// document.querySelector("button").addEventListener("click", () => anim.restart());
This Pen doesn't use any external CSS resources.