JSFiddle - React, Tailwind, and code Playground
HTML
<div id="containerDragable">
<img id="img_messi" src="http://www.elconfidencial.com/fotos/noticias_2011/2012090245messi_dentro.jpg" />
<div id="text_example">hi!</div>
</div>
CSS
#containerDragable {
font-size: 24px;
width: 80vw;
height: 45vw;
background-color: rgb(227, 227, 227);
margin: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
position:absolute;
}
#containerDragable > * {
cursor: pointer;
position: absolute;
display: block;
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
-ms-transform-origin: 0 0;
-o-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scale(0.5);
border: 1px solid red;
}
JavaScript
$(function () {
$('#containerDragable > *').each(function(){
$(this).css('margin', '0 -'+($(this).width()/2)+'px -'+($(this).height()/2)+'px 0');
$(this).draggable({
containment: "#containerDragable", cursor: "move", scroll: false
});
});
});