边界半径:50%不工作|CSS/HTML/JS格式

to94eoyn  于 2023-03-20  发布在  其他
关注(0)|答案(2)|浏览(126)

这里的要点是设置鼠标的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>
7cwmlq89

7cwmlq891#

我猜你是指第二行的身高,这就成了一个问题

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

因此只需将其更改为高度:

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

pxyaymoc2#

更改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;
}
<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>

相关问题