Home  >  Q&A  >  body text

Border radius: 50% does not work | CSS/HTML/JS

The point here is to set the div's position to the mouse as an additional effect, it should have a radius, but it doesn'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>

P粉462328904P粉462328904205 days ago399

reply all(2)I'll reply

  • P粉107991030

    P粉1079910302024-04-01 12:09:34

    Change your CSS. Width: 6px; Width: 6px; 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;
    }
    sssccc
    

    reply
    0
  • P粉125450549

    P粉1254505492024-04-01 10:44:17

    I'm assuming you're referring to the height of the second row here, which makes it a problem

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

    So just change it to height:

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

    reply
    0
  • Cancelreply