Drag and Drop Demo
by lotabout
HTML
<div id="drag-container">
<div class="dropzone">
<div id="draggable" draggable="true">
Drag Me
</div>
</div>
<div class="dropzone"></div>
<div class="dropzone"></div>
</div>
CSS
#drag-container {
display: flex;
justify-content: space-between;
}
#drag-container > .dropzone {
width: 150px;
height: 150px;
background: #dae8fc;
padding: 10px;
border: 1px solid #6c8ebf;
display: flex;
flex-direction: column;
justify-content: center;
}
#draggable {
width: 90px;
height: 90px;
line-height: 90px;
text-align: center;
background: #f8cecc;
border: 1px solid #b85450;
margin: 0 auto;
cursor: pointer;
}
JavaScript
let draggable = document.getElementById('draggable');
draggable.addEventListener('dragstart', (ev) => {
ev.dataTransfer.setData('text/plain', null);
});