如何制作一个使用鼠标旋转的按钮,这样可以获得旋转多少度的值(如在汽车方向盘中)?
答案 0 :(得分:0)
试试这个:
var degree = 0;
document.addEventListener("mousewheel", function(event) {
if (event.wheelDelta == 120) {
degree++;
} else {
degree--;
}
var button = document.querySelector("#button");
button.style.transform = "rotate(" + degree + "deg)";
button.style.mozTransform = "rotate(" + degree + "deg)";
button.style.webkitTransform = "rotate(" + degree + "deg)";
})