JSFiddle - React, Tailwind, and code Playground
HTML
<div></div>
CSS
div {
width: 100px;
height: 100px;
background-color: red;
position: static;
top: auto;
left: auto;
-webkit-transition: all 4s linear;
transition: all 4s linear;
}
div.fixed {
background-color: yellow;
position: fixed;
top: 50%;
left: 50%;
}
JavaScript
$('div').click(function() {
$(this).toggleClass('fixed');
});