首頁  >  問答  >  主體

邊框半徑:50% 不起作用 | CSS/HTML/JS

這裡的重點是將div的位置設為滑鼠作為附加效果,它應該有一個半徑,但它不起作用:

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 天前403

全部回覆(2)我來回復

  • P粉107991030

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

    更改你的 CSS。寬度:6 像素;寬度:6 像素;寬度:6px;高度: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
    

    回覆
    0
  • P粉125450549

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

    我假設你指的是這裡第二行的高度,這使得它成為一個問題

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

    所以只需將其更改為高度:

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

    回覆
    0
  • 取消回覆