HTML Code

3D Transform Playground

3D Transform Playground

3D Transform Playground

0


1
2
3
4
5
6

3D Transform Playground Code :


<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<title>3D Transform Playground</title>
<style>
body {
font-family: sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
background-color: #f0f0f0;
}

#controls {
display: flex;
gap: 10px;
margin-bottom: 20px;
}

#preview-container {
width: 200px;
height: 200px;
perspective: 500px;
margin-bottom: 20px;
}

#preview-box {
width: 100%;
height: 100%;
transform-style: preserve-3d;
transition: transform 0.5s ease-in-out;
background-color: rgba(0, 123, 255, 0.3);
border: 1px solid #007bff;
}

.face {
position: absolute;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 2em;
color: white;
background-color: rgba(0,0,0,0.5);
border: 1px solid black;
}

.front { transform: translateZ(100px); }
.back { transform: rotateY(180deg) translateZ(100px); }
.right { transform: rotateY(90deg) translateZ(100px); }
.left { transform: rotateY(-90deg) translateZ(100px); }
.top { transform: rotateX(90deg) translateZ(100px); }
.bottom { transform: rotateX(-90deg) translateZ(100px); }
</style>
</head>
<body>
<h1>3D Transform Playground</h1>

<div id=”controls”>
<select id=”transform-type”>
<option value=”rotateX”>rotateX</option>
<option value=”rotateY”>rotateY</option>
<option value=”rotateZ”>rotateZ</option>
</select>
<input type=”range” id=”transform-value” min=”0″ max=”360″ value=”0″>
<span id=”transform-value-display”>0</span>
</div>

<div id=”preview-container”>
<div id=”preview-box”>
<div class=”face front”>1</div>
<div class=”face back”>2</div>
<div class=”face right”>3</div>
<div class=”face left”>4</div>
<div class=”face top”>5</div>
<div class=”face bottom”>6</div>
</div>
</div>

<script>
const transformTypeSelect = document.getElementById(‘transform-type’);
const transformValueInput = document.getElementById(‘transform-value’);
const transformValueDisplay = document.getElementById(‘transform-value-display’);
const previewBox = document.getElementById(‘preview-box’);

transformValueInput.addEventListener(‘input’, function() {
const value = this.value;
transformValueDisplay.textContent = value;
const transformType = transformTypeSelect.value;
previewBox.style.transform = `${transformType}(${value}deg)`;
});

transformTypeSelect.addEventListener(‘change’, function() {
const value = transformValueInput.value;
transformValueDisplay.textContent = value;
const transformType = this.value;
previewBox.style.transform = `${transformType}(${value}deg)`;
});
</script>
</body>
</html>


 

Scroll to Top