<body>
<div class="container">
<div class="outer">
<div class="inner"></div>
</div>
<div class="range">
<label for="perspective">Perspective</label>
<input type="range" class='perspective' id="perspective" step=1 min=5 max=500 value=250>
<span class='per-text'></span>
<label for="degree">Degree</label>
<input type="range" class="degree" id='degree' step=1 min=0 max=360 value=180>
<span class='deg-text'></span>
</div>
</div>
</body>
body {
width: 100%;
margin: 0;
padding: 0;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 2rem;
}
.outer,
.inner {
width: 10rem;
height: 10rem;
}
.outer {
border: 1px solid black;
}
.inner {
border: 1px solid red;
background: red;
opacity: 0.5;
transform: rotateY(45deg);
}
.range {
width: 18rem;
text-align: center;
}
const outer = document.querySelector(".outer");
const inner = document.querySelector(".inner");
const perspective = document.querySelector(".perspective");
const perspectiveText = document.querySelector(".per-text");
const degree = document.querySelector(".degree");
const degreeText = document.querySelector(".deg-text");
perspective.addEventListener("input", (e) => {
outer.style.perspective = e.target.value + "rem";
perspectiveText.innerText = e.target.value + "rem";
});
degree.addEventListener("input", (e) => {
inner.style.transform = `rotateY(${e.target.value}deg)`;
degreeText.innerText = e.target.value + "deg";
});
window.addEventListener("load", () => {
perspectiveText.innerText = perspective.value + "rem";
degreeText.innerText = degree.value + "deg";
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.