JSFiddle - React, Tailwind, and code Playground

by momenelkamri

HTML

<div class="square click" id="move" onclick="move(this)">
</div>

SCSS

@keyframes movem {
  0% {
    left: 0px;
  }

  50% {
    left: 300px;
    top: 0px;
    opacity: 1;
  }

  100% {
    top: 200px;
    left: 300px;
    opacity: 0;
  }
}

.square {
  left: 0px;
  top: 0px;
  position: absolute;
  width: 100px;
  height: 100px;
  background: red;
}

.move {
  animation: movem 5s ease;
  animation-fill-mode: forwards;
}

.click {
  cursor: pointer;
}

JavaScript

function move(el) {
document.getElementById('move').classList.add('move');
document.getElementById('move').classList.remove('click');
}