JSFiddle - React, Tailwind, and code Playground

HTML

<div class="container">
    <div class="box"></div>
</div>

CSS

.container { width: 450px; height: 52px; border: 1px #000 solid; position: relative; }
.box { width: 50px; height: 50px; border: 1px #000 solid; position: absolute; right: 200px; }

JavaScript

$(document).ready(function(){
  $('div.container').mousemove(function(e){
        var x = e.pageX - this.offsetLeft;
      if (x <= 400) {
          $('div.box').css({'right': x}); 
      }
  });
});