When I get mouse's x and y values both of my elements are sliding. I have already tried position:relativein css and I checked some of stackoverflow articles. Where I had made the mistake ?
window.addEventListener("mousemove", e =>{
document.getElementById("x-value").textContent= e.x ;
}
)
html,body{
margin: 0;
padding: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
align-items: center;
}
p{
margin:0px 5px;
padding: 0;
}
span *{
display: inline;
position: relative;
max-width: 20%;
}
div{
width: 500px;
display: flex;
flex-direction: row;
justify-content: space-around;
}
<div>
<p>X = <span id="x-value"> </span> </p>
<p>Y = <span id="y-value"> </span> </p>
</div>