I'm attempting to rotate a red circle with the ID of outer using Input[type=range]
. I've tried selecting the circle's style, then transforming it based on the input value, but it needs to be within the parentheses of rotateZ()
, which requires a string. Here is my code:
var value = document.getElementById("slider").value;
console.log(value);
document.getElementById("inner").style.transform = document.getElementById("slider").value;
body {
display:flex;
align-items:center;
justify-content:center;
}
#outer {
background:red;
height:20vw;
position:relative;
border-radius:50%;
width:20vw;
display:flex;
justify-content:center;
}
#inner {
transform:translateY(10%);
border-bottom-left-radius:100%;
border-bottom-right-radius:100%;
position:absolute;
bottom:0;
background:darkgreen;
width:10%;
height:50%;
}
<div id="outer"><div id="inner"></div></div>
<input min="0" max="360" type="range" id="slider">
Unfortunately, the current implementation is not functioning as expected. The challenge lies in correctly formatting the value within parentheses.
UPDATE, SOLUTION:
To overcome this issue, I utilized Template Literals by enclosing the variable within {}
inside the rotate function's parentheses.