<div class="control">
<label for="angle">Angle:</label>
<input type="range" id="angle" name="angle" value="0" min="0" max="360" step="1" />
<output id="output">0deg</output>
</div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
min-height: 100vh;
font-family: "Exo", Arial, sans-serif;
background-color: #222;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
}
:root {
--angle: 0deg;
}
body {
background-image: conic-gradient(from var(--angle), #09f, #f36);
}
View Compiled
const rootElement = document.documentElement;
const angleInput = document.getElementById("angle");
const angleOutput = document.getElementById("output");
angleInput.addEventListener("input", (etv) => {
rootElement.style.setProperty("--angle", `${etv.target.value}deg`);
angleOutput.innerText = `${etv.target.value}deg`;
});
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.