JSFiddle - React, Tailwind, and code Playground

HTML

<div id="mydiv"></div>

CSS

#mydiv{
    width:400px;
    height:400px;
    position:absolute;
    left:0;
    
    background: black;
}

JavaScript

//This will not work but if you replace 'left':'0px' with 'left':'200px' and then replace 'right':'0px' with 'left':'0px, the script will animate the div.

$(document).ready(function() {

var width = $(document).width() - $('#mydiv').width();
    
function animateMydiv() {
$('#mydiv').animate({'right': width + 'px'}, 1000);
    
}

animateMydiv();
});