JSFiddle - React, Tailwind, and code Playground

by Chris

HTML

<div id="container"></div>

CSS

#container {
    height: 100px;
    width: 100px;
    border: solid 1px black;
}

JavaScript

window.onload = function start() {
    slide();
}

function slide() {
    var currMarg = 0,
        contStyle = document.getElementById('container').style;
    setInterval(function() {
        currMarg = currMarg == 1800 ? 0 : currMarg + 600;
        contStyle.marginLeft = currMarg + 'px';
    }, 3000);
}