JSFiddle - React, Tailwind, and code Playground
by Raloynner
HTML
<div id="your-element-id" class="container">
</div>
<div id="your-element-id2" class="div">
</div>
CSS
body{
margin: 0;
}
*{
box-sizing: border-box
}
.container{
width: 500px;
margin: 0 auto;
height: 400px;
border: 1px solid;
}
.div{
height: 400px;
margin-left: calc(100vw - 500px - 50%);
background-color: red;
margin-top: 20px;
}
JavaScript
const item = document.getElementById('your-element-id');
const style= getComputedStyle(item);
const itemTopmargin = style.marginLeft;
console.log(itemTopmargin);
const item2 = document.getElementById('your-element-id2').style.marginLeft = itemTopmargin;