3D Text Shadow
Home
Snippets
3D Text Shadow
HTML
CSS
JS
<div class="wrap"> <h1 id="title">3D Text</h1> <div class="underline" aria-hidden="true"></div> </div>
:root{ --bg1:#0b1220; --bg2:#0e1a33; --glow:#74ffd9; --accent:#13d18f; --dark:#06101a; } html,body{ height:100%; margin:0} body{ display:flex; align-items: center; justify-content: center; background: radial-gradient(1200px 800px at 70% 20%, var(--bg2), var(--bg1)); font-family: "Poppins", system-ui, -apple-system, Segoe UI, Roboto, Arial; } .wrap{ perspective: 1200px; display:flex; flex-direction: column; align-items: center; justify-content: center; } h1{ --depth: 20; --size: clamp(42px, 10vw, 80px); --tiltX: 0deg; --tiltY: 0deg; font-size: var(--size); margin:0; letter-spacing:.02em; line-height: .95; text-transform: uppercase; position: relative; transform: rotateX(var(--tiltX)) rotateY(var(--tiltY)); transform-style: preserve-3d; transition: transform .15s ease-out; background: linear-gradient(100deg, #fff 0%, #c8fff0 20%, #9df7dd 40%, #c8fff0 60%, #fff 80%) 0 0 / 200% 100% no-repeat, linear-gradient(180deg, #eafff8, #b3ffe8); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 10px 24px rgba(19,209,143,.25)); } .underline{ height:8px; width:min(60ch, 80vw); background: linear-gradient(90deg, transparent, rgba(116,255,217,.35), transparent); border-radius:99px; margin-top:34px; filter: blur(4px); }
(function(){ const title = document.getElementById('title'); const DEPTH = 20; const STEP = 1.1; const AX = 0.9; const AY = 1.6; const BASE = { r: 9, g: 31, b: 45 }; const GLOW = { r: 19, g: 209, b: 143 }; const shades = []; for(let i=1;i<=DEPTH;i++){ const t = i / DEPTH; const r = Math.round(BASE.r + (GLOW.r-BASE.r)*t); const g = Math.round(BASE.g + (GLOW.g-BASE.g)*t); const b = Math.round(BASE.b + (GLOW.b-BASE.b)*t); const a = 0.95 - t*0.75; const x = (AX * STEP * i).toFixed(2); const y = (AY * STEP * i).toFixed(2); shades.push(`${x}px ${y}px 0 rgba(${r},${g},${b},${a})`); } shades.push(`0 22px 18px rgba(0,0,0,.35)`); title.style.textShadow = shades.join(','); const wrap = document.querySelector('.wrap'); const clamp = (n, min, max) => Math.max(min, Math.min(max, n)); window.addEventListener('mousemove', (e)=>{ const rect = wrap.getBoundingClientRect(); const cx = rect.left + rect.width/2; const cy = rect.top + rect.height/2; const dx = (e.clientX - cx) / (rect.width/2); const dy = (e.clientY - cy) / (rect.height/2); const tiltX = clamp(-dy * 10, -12, 12); const tiltY = clamp( dx * 14, -16, 16); title.style.setProperty('--tiltX', tiltX.toFixed(2)+'deg'); title.style.setProperty('--tiltY', tiltY.toFixed(2)+'deg'); }); window.addEventListener('touchstart', ()=>{ title.animate( [{ transform: 'scale(1)' }, { transform: 'scale(1.03)' }, { transform: 'scale(1)' }], { duration: 350, easing: 'ease-out' } ); }, {passive:true}); })();
Ad #1
Ad #2
Scroll to Top