skip to Main Content

Point of this is to set the position of the div to the mouse as a added effect, it was supposed to have a radius, but it didn’t work:

let inner_circle = document.getElementById("inner_circle");

window.addEventListener("mousemove", function(mouse) {
  inner_circle.style.transform = `translate(${mouse.clientX}px, ${mouse.clientY}px)`; // sets the position of the inner circle to the mouse
});
#inner_circle{
    margin-left: -3px;
    margin-top: -3px;
    position: fixed;
    top: 0;
    left: 0;
    border: 1px solid #703be7;
    border-radius: 50%; //<- doesn't work
    font-size: 1px;
    background-color: #703be7;
    width: 6px;
    width: 6px;
    z-index: 1000001;
    pointer-events: none;
}
<div id="inner_circle"></div>

2

Answers


  1. I assume you meant height on the second line here and this makes it a problem

    #inner_circle{
    width: 6px;
    width: 6px;
    }
    
    

    so just change it to height:

    #inner_circle{
    width: 6px;
    height: 6px;
    }
    
    
    Login or Signup to reply.
  2. Change your css. width: 6px;width: 6px; to width: 6px;height: 6px;

    let inner_circle = document.getElementById("inner_circle");
    
    window.addEventListener("mousemove", function(mouse) {
      inner_circle.style.transform = `translate(${mouse.clientX}px, ${mouse.clientY}px)`; // sets the position of the inner circle to the mouse
    });
    #inner_circle{
        margin-left: -3px;
        margin-top: -3px;
        position: fixed;
        top: 0;
        left: 0;
        border: 1px solid #703be7;
        border-radius: 50%; //<- doesn't work
        font-size: 1px;
        background-color: #703be7;
        width: 6px;
        height: 6px;
        z-index: 1000001;
        pointer-events: none;
    }
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <div id="inner_circle" style="background-color: rgb(0, 0, 0);"></div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search