gsap+css炫酷鼠标悬浮图片视觉差异立体动画效果代码
代码语言:html
所属分类:视觉差异
代码描述:gsap+css炫酷鼠标悬浮图片视觉差异立体动画效果代码,可选择不同形状、3d等参数调整。
代码标签: gsap css 炫酷 鼠标 悬浮 图片 视觉 差异 立体 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { /* 3D deck tuning */ --depth-step: 36px; --scale-3d: 0.07; --tilt-max: 45; --pan-max: 88px; --stack-scale: 1; --opacity-falloff: 0.1; --idle-rotY: 0; --idle-rotX: 0; --move-amplify: 0.54; --tilt-boost: 1.25; --pan-boost: 1.25; --depth-boost: 1.15; --scale-boost: 0.96; } * { margin: 0; padding: 0; box-sizing: border-box; } body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #000; color: #fff; font-family: system-ui, -apple-system, sans-serif; gap: 30px; position: relative; background-image: url("data:image/svg+xml,%3csvg width='20' height='20' xmlns='http://www.w3.org/2000/svg'%3e%3cdefs%3e%3cpattern id='dot' patternUnits='userSpaceOnUse' width='20' height='20'%3e%3ccircle cx='10' cy='10' r='1' fill='%23222'/%3e%3c/pattern%3e%3c/defs%3e%3crect width='100%25' height='100%25' fill='url(%23dot)'/%3e%3c/svg%3e"); } .image-container { position: relative; width: 600px; height: 600px; cursor: pointer; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.15); } .image-container.is-3d { perspective: 1600px; perspective-origin: 50% 50%; overflow: visible; isolation: isolate; } .image-stack { position: absolute; inset: 0; transform-style: flat; will-change: transform; } .image-container.is-3d .image-stack { transform-style: preserve-3d; } .image-layer { position: absolute; inset: 0; background-image: url("//repo.bfw.wiki/bfwrepo/image/5fc1a7bc2bc81.png"); background-size: cover; background-position: center; background-repeat: no-repeat; -webkit-backface-visibility: hidden; backface-visibility: hidden; will-change: transform, opacity; } .image-layer:not(:first-child) { opacity: 0; transform: scale(0.95); } .image-layer.rectangle { -webkit-clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%); clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%); } .image-layer.circle { -webkit-clip-path: circle(45% at 50% 50%); clip-path: circle(45% at 50% 50%); } .image-layer.diamond { -webkit-clip-path: polygon(50% 0%, 14.1% 50%, 50% 100%, 85.9% 50%); clip-path: polygon(50% 0%, 14.1% 50%, 50% 100%, 85.9% 50%); } .image-layer.hexagon { -webkit-clip-path: polygon( 25% 6.7%, 75% 6.7%, 100% 50%, 75% 93.3%, 25% 93.3%, 0% 50% ); clip-path: polygon( 25% 6.7%, 75% 6.7%, 100% 50%, 75% 93.3%, 25% 93.3%, 0% 50% ); } .controls { display: flex; justify-content: space-between; align-items: flex-start; width: 600px; position: relative; } .shape-controls { display: flex; gap: 10px; align-items: center; } .shape-btn { width: 16px; height: 16px; background: #fff; border: none; cursor: pointer; transition: opacity 0.3s ease; } .shape-btn:hover { opacity: 0.8; } .shape-btn.active { opacity: 1; } .shape-btn:not(.active) { opacity: 0.5; } .shape-btn[data-shape="circle"] { border-radius: 50%; } .shape-btn[data-shape="diamond"] { transform: rotate(45deg); width: 14px; height: 14px; } .shape-btn[data-shape="hexagon"] { -webkit-clip-path: polygon( 25% 6.7%, 75% 6.7%, 100% 50%, 75% 93.3%, 25% 93.3%, 0% 50% ); clip-path: polygon( 25% 6.7%, 75% 6.7%, 100% 50%, 75% 93.3%, 25% 93.3%, 0% 50% ); width: 19px; height: 19px; } .toggle-controls { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; position: relative; } .toggle-btn { background: none; border: none; color: #9ca3af; cursor: pointer; font-family: "PP Supply Mono", monospace; font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.5px; transition: color 0.2s ease; } .toggle-btn:hover { color: #fff; } .toggle-btn.active { color: #4ade80; } .toggle-btn:disabled { color: #555; cursor: not-allowed; } .credit { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); font-family: "PP Supply Mono", monospace; font-size: 0.75em; color: rgba(255, 255, 255, 0.3); text-decoration: none; text-transform: uppercase; letter-spacing: 0.5px; transition: opacity 0.2s ease; } .credit:hover { opacity: 0.8; color: rgba(255, 255, 255, 0.5); } @media (max-width: 768px) { .image-container { width: 400px; height: 400px; } .controls { width: 400px; } } @media (max-width: 480px) { .image-container { width: 300px; height: 300px; }.........完整代码请登录后点击上方下载按钮下载查看
网友评论0