To position a DIV in a specific coordinates with JavaScript, we set the left
and top
properties.
For instance, we write
const d = document.getElementById("yourDivId");
d.style.position = "absolute";
d.style.left = "10px";
d.style.top = "20px";
to select the element with getElementById
.
We set its position
to 'absolute'
.
And then we set the left
and top
position to shift it horizontally and vertically.