One way to achieve this is by determining the click position relative to the parent tag, and then adjusting the child tag's position using the 'left' and 'top' styles.
// Get references to the parent and child elements
let outer = document.getElementById("container");
let inner = document.getElementById("circle");
// Add a click event listener to the parent element
outer.addEventListener("click", function(event) {
// Calculate the new position for the child element
let result = {
Azimut: {
x: event.offsetX,
y: event.offsetY,
},
Size: 10,
}
// Adjust the child element's position based on the click coordinates
inner.style.top = (result.Azimut.y - result.Size / 2) + "px";
inner.style.left = (result.Azimut.x - result.Size / 2) + "px";
inner.style.width = result.Size + "px";
inner.style.height = result.Size + "px";
})
<div id="container" style="
width: 100px;
height: 100px;
border: 1px solid black;
position: relative;">
<div id="circle" style="
border: 1px solid black;
position: absolute;
"></div>
<div>