慢速演示Hanoi塔递归函数解题过程!DOCTYPE html html lang="zh-CN" head meta charset="UTF-8" meta content="width=device-width, initial-scale=1.0" title汉诺塔递归可视化/title style * { box-sizing: border-box; margin: 0; padding: 0; } body { background: #0f172a; color: #e2e8f0; font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 20px; } h1 { font-size: 1.6rem; color: #7dd3fc; margin-bottom: 6px; letter-spacing: 2px; } .subtitle { font-size: 0.85rem; color: #64748b; margin-bottom: 18px; } /* Controls */ .controls { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; justify-content: center; } .controls label { font-size: 0.85rem; color: #94a3b8; } select, button { padding: 6px 14px; border-radius: 8px; border: 1px solid #334155; background: #1e293b; color: #e2e8f0; font-size: 0.85rem; cursor: pointer; transition: background 0.2s; } button:hover { background: #2d3f55; } button.primary { background: #0369a1; border-color: #0284c7; } button.primary:hover { background: #0284c7; } button:disabled { opacity: 0.4; cursor: not-allowed; } /* Speed slider */ .speed-wrap { display: flex; align-items: center; gap: 8px; } input[type=range] { width: 90px; accent-color: #38bdf8; } /* Tower scene */ .scene { background: #1e293b; border: 1px solid #334155; border-radius: 16px; padding: 20px 30px 10px; width: 100%; max-width: 720px; margin-bottom: 14px; position: relative; } .towers-wrap { display: flex; justify-content: space-around; align-items: flex-end; height: 220px; position: relative; margin-bottom: 0; } .tower { display: flex; flex-direction: column; align-items: center; width: 30%; position: relative; } .peg { width: 8px; background: linear-gradient(to bottom, #64748b, #94a3b8); border-radius: 4px 4px 0 0; position: absolute; bottom: 28px; height: 170px; left: 50%; transform: translateX(-50%); z-index: 1; } .base-line { width: 100%; height: 6px; background: linear-gradient(90deg, #334155, #475569, #334155); border-radius: 3px; position: absolute; bottom: 24px; } .disks-area { width: 100%; height: 170px; position: absolute; bottom: 32px; left: 0; display: flex; flex-direction: column-reverse; align-items: center; justify-content: flex-start; z-index: 2; } .disk { height: 22px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.9); text-shadow: 0 1px 2px rgba(0,0,0,0.5); position: relative; transition: none; flex-shrink: 0; } .disk.moving { box-shadow: 0 0 18px 4px rgba(251,191,36,0.7); z-index: 10; } .tower-label { font-size: 1rem; font-weight: 700; color: #7dd3fc; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); } /* Flying disk overlay */ #flyDisk { position: fixed; z-index: 100; border-radius: 11px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.9); text-shadow: 0 1px 2px rgba(0,0,0,0.5); pointer-events: none; box-shadow: 0 0 20px 5px rgba(251,191,36,0.8); display: none; } /* Call stack */ .stack-panel { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 12px 16px; width: 100%; max-width: 720px; margin-bottom: 12px; min-height: 70px; } .stack-title { font-size: 0.75rem; color: #64748b; margin-bottom: 8px; letter-spacing: 1px; text-transform: uppercase; } .stack-frames { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; } .frame { background: #0f172a; border: 1px solid #334155; border-radius: 6px; padding: 4px 10px; font-size: 0.78rem; font-family: 'Consolas', monospace; color: #a5f3fc; transition: all 0.3s; } .frame.active { background: #0c4a6e; border-color: #38bdf8; color: #e0f2fe; box-shadow: 0 0 8px rgba(56,189,248,0.4); } .frame-arrow { color: #475569; font-size: 0.9rem; }