Randradius: 50 % funktioniert nicht | CSS/HTML/JS
P粉462328904
P粉462328904 2024-03-31 12:57:32
0
2
363

Hier geht es darum, die Position des Divs als zusätzlichen Effekt auf die Maus festzulegen. Es sollte einen Radius haben, aber es funktioniert nicht:

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粉462328904
P粉462328904

Antworte allen(2)
P粉107991030

更改你的 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%; //

P粉125450549

我假设你指的是这里第二行的高度,这使得它成为一个问题

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

所以只需将其更改为高度:

#inner_circle{
width: 6px;
height: 6px;
}
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!