JSFiddle - React, Tailwind, and code Playground
HTML
<div class="el off">off</div>
CSS
* { padding: 0; margin: 0 }
.el {
width: 120px;
height: 120px;
background: red;
color: white;
cursor: pointer;
transition: transform 0.65s ease 0.15s;
transform: translateX(120px);
}
.el.off {
transform: translate(0, 0);
}
@media screen and (max-width: 425px) {
.el {
background: blue;
transform: translateY(120px);
}
}
JavaScript
$(".el").click(function() {
if ( $(this).hasClass("off") ) {
$(this).removeClass("off");
$(this).html("on");
} else {
$(this).addClass("off");
$(this).html("off");
}
});