JSFiddle - React, Tailwind, and code Playground

by Nickolay Ilchenko

HTML

Before Before Before
<div id="moving-div">Text Text Text
    <br/>Text Text Text
    <br/>
</div>
After After After

CSS

#moving-div {
      border: 5px groove green;
      background-color: yellow;
      padding: 5px;
      margin: 10px;
  }

JavaScript

var div = document.getElementById('moving-div');
div.style.position = 'absolute';
div.style.right = div.style.top = 0;
var newDiv = document.createElement('div');
newDiv.style.position = 'relative';
newDiv.style.border = getComputedStyle(div).border;
newDiv.style.height = div.offsetHeight + 'px';
document.body.insertBefore(newDiv, div);