-
3D CSS function Animation
HTML
CSS
JavaScript
3D Rotating Cube
3D Flip Card (Tap)
Tap
Flip
3D Depth Text
3D TEXT
3D Tilt Effect
Touch
3D Carousel
1
2
3
4
body { margin: 0; font-family: sans-serif; background: #020617; color: #fff; } .section { display: flex; flex-direction: column; min-height: 100vh; border-bottom: 1px solid #222; } @media (min-width: 768px) { .section { flex-direction: row; } } /* TITLE */ .title { position: absolute; top: 10px; left: 20px; font-size: 18px; font-weight: bold; color: cyan; } /* CONTAINERS */ .preview, .code { flex: 1; position: relative; padding: 40px 20px 20px; } .preview { display: flex; justify-content: center; align-items: center; perspective: 1000px; } .code { background: #111; overflow: auto; } pre { color: #00ffcc; font-size: 13px; white-space: pre-wrap; } /* ---------- CUBE ---------- */ .cube { width: 100px; height: 100px; transform-style: preserve-3d; animation: spin 5s infinite linear; position: relative; } .face { position: absolute; width: 100px; height: 100px; background: cyan; opacity: 0.7; border: 1px solid #fff; } .front { transform: translateZ(50px); } .back { transform: rotateY(180deg) translateZ(50px); } .right { transform: rotateY(90deg) translateZ(50px); } .left { transform: rotateY(-90deg) translateZ(50px); } .top { transform: rotateX(90deg) translateZ(50px); } .bottom { transform: rotateX(-90deg) translateZ(50px); } @keyframes spin { to { transform: rotateX(360deg) rotateY(360deg); } } /* ---------- FLIP ---------- */ .card { width: 180px; height: 220px; } .inner { width: 100%; height: 100%; transform-style: preserve-3d; transition: 0.6s; } .card:active .inner { transform: rotateY(180deg); } .frontCard, .backCard { position: absolute; width: 100%; height: 100%; display:flex; justify-content:center; align-items:center; backface-visibility: hidden; } .frontCard { background: cyan; } .backCard { background: magenta; transform: rotateY(180deg); } /* ---------- TEXT ---------- */ .text3d { font-size: 40px; text-shadow: 3px 3px 0 #444; animation: pop 1s infinite alternate; } @keyframes pop { to { transform: translateZ(40px); } } /* ---------- TILT ---------- */ .tilt { width: 180px; height: 180px; background: linear-gradient(45deg, cyan, purple); display:flex; align-items:center; justify-content:center; transition: 0.3s; } .tilt:active { transform: rotateX(20deg) rotateY(20deg); } /* ---------- CAROUSEL ---------- */ .carousel { width: 150px; height: 150px; transform-style: preserve-3d; animation: rotate 8s infinite linear; position: relative; } .item { position: absolute; width: 100px; height: 120px; background: cyan; text-align:center; line-height:120px; } .item:nth-child(1){ transform: rotateY(0) translateZ(200px); } .item:nth-child(2){ transform: rotateY(90deg) translateZ(200px); } .item:nth-child(3){ transform: rotateY(180deg) translateZ(200px); } .item:nth-child(4){ transform: rotateY(270deg) translateZ(200px); } @keyframes rotate { to { transform: rotateY(360deg); } }
let currentMethod = 'phone'; const DEMO_CODE = "246810"; function setMethod(method) { currentMethod = method; document.querySelectorAll('.method-btn').forEach(btn => btn.classList.remove('active')); event.target.classList.add('active'); document.getElementById('phoneField').style.display = method === 'phone' ? 'block' : 'none'; document.getElementById('emailField').style.display = method === 'email' ? 'block' : 'none'; } function sendCode() { const target = currentMethod === 'phone' ? document.getElementById('phoneInput').value : document.getElementById('emailInput').value; if (!target) return; document.getElementById('displayTarget').innerText = target; document.getElementById('step1').classList.remove('active'); document.getElementById('step2').classList.add('active'); document.querySelectorAll('.otp-input')[0].focus(); } function moveNext(el, index) { const inputs = document.querySelectorAll('.otp-input'); if (el.value && index < 5) { inputs[index + 1].focus(); } } function verifyCode() { const inputs = document.querySelectorAll('.otp-input'); let code = ""; inputs.forEach(input => code += input.value); if (code === DEMO_CODE) { document.getElementById('step2').classList.remove('active'); document.getElementById('step3').classList.add('active'); } else { document.getElementById('errorCode').style.display = 'block'; inputs.forEach(input => { input.value = ""; input.style.borderColor = "#ff5f5f"; }); inputs[0].focus(); } } function goBack() { document.getElementById('step2').classList.remove('active'); document.getElementById('step1').classList.add('active'); document.getElementById('errorCode').style.display = 'none'; }
Live Preview