gsap+svg实现带视觉差异的模糊卡片鼠标交互效果代码
代码语言:html
所属分类:视觉差异
代码描述:gsap+svg实现带视觉差异的模糊卡片鼠标交互效果代码
代码标签: gsap svg 视觉差异 模糊 卡片 鼠标 交互
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.css"> <style> @import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap'); *, *:after, *:before { box-sizing: border-box; } html { color-scheme: light only; } body { display: flex; place-items: center; justify-content: center; min-height: 100vh; touch-action: none; font-family: "SF Pro Text", "SF Pro Icons", "AOS Icons", "Helvetica Neue", Helvetica, Arial, sans-serif, system-ui; padding: 1rem; } body::before { --line: color-mix(in lch, canvasText 25%, transparent); --size: 60px; content: ""; height: 100vh; width: 100vw; position: fixed; background: linear-gradient(90deg, var(--line) 1px, transparent 1px var(--size)) 0 -5vmin / var(--size) var(--size), linear-gradient(var(--line) 1px, transparent 1px var(--size)) 0 -5vmin / var(--size) var(--size); -webkit-mask: linear-gradient(-15deg, transparent 60%, white); mask: linear-gradient(-15deg, transparent 60%, white); top: 0; z-index: -1; } article { width: 600px; aspect-ratio: 2 / 1.1; min-height: 330px; position: relative; overflow: hidden; border-radius: 4em; max-width: calc(100% - 2rem); background: hsl(0 0% 50%); } article > img { position: absolute; top: 0; left: 50%; translate: -50% 0; height: 100%; width: 660px; -o-object-fit: cover; object-fit: cover; -o-object-position: center 43%; object-position: center 43%; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; pointer-events: none; } :root { --x: 0; --y: 0; } article > img:first-of-type { filter: saturate(1.5) brightness(0.9); -o-object-position: calc(-50% + (var(--x) * 30px)) calc(43% + (var(--y) * -20px)); object-position: calc(-50% + (var(--x) * 30px)) calc(43% + (var(--y) * -20px)); } article > img:last-of-type { -o-object-position: calc(-50% + (var(--x) * 40px)) calc(43% + (var(--y) * -40px)); object-position: calc(-50% + (var(--x) * 40px)) calc(43% + (var(--y) * -40px)); } article h3 { position: absolute; left: 50%; top: 6%; margin: 0; font-size: 8rem; translate: -50% 0; text-transform: uppercase; font-family: 'Bebas Neue', sans-serif; color: white; translate: calc(-50% + (var(--x) * -30px)) calc(var(--y) * -20px); } .content { min-height: 32%; position: absolute; bottom: 0; width: 100%; color: white; display: grid; gap: 0.2rem; place-items: center; align-content: center; padding-bottom: .5rem; } .content svg { width: 20px; } .content p { margin: 0; display: flex; align-items: center; gap: 0.5rem; font-size: 1.2rem; } .content p:first-of-type::after { content: ""; position: absolute; top: 1rem; left: 50%; width: 6ch; background: white; height: 1px; translate: -50% 0; } .content p:last-of-type { opacity: 0.8; } /* Blurring */ .blur { position: absolute; inset: 60% 0 -26% 0; filter: blur(20px); overflow: hidden; } .blur img { -o-object-position: calc(-50% + (var(--x) * 40px)) calc(47.5% + (var(--y) * -4.........完整代码请登录后点击上方下载按钮下载查看
网友评论0