js+css实现图片鼠标悬浮移动视觉差异动画效果代码
代码语言:html
所属分类:视觉差异
代码描述:js+css实现图片鼠标悬浮移动视觉差异动画效果代码,使用了svg的filter来实现。
代码标签: js css 图片 鼠标 悬浮 移动 视觉差异 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Zeyada&display=swap'> <style> @import url("https://fonts.googleapis.com/css2?family=Danfo&display=swap"); body { display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100vw; height: 100vh; margin: 0; overflow: hidden; background: #799df1; cursor: crosshair; } img { max-width: 90vw; max-height: calc(95vh - 1.5rem); margin-bottom: 2rem; filter: url(#3d); } .footer { position: absolute; bottom: 0; left: 0; display: flex; justify-content: space-between; width: 100%; font-family: sans-serif; font-weight: 700; color: white; text-transform: uppercase; } .text, .buttons { padding: 0.5rem; } button { margin: 0 0.2rem; border: none; color: white; background-color: #000038; border-radius: 1rem; cursor: pointer; } .button-active { color: #000038; background-color: white; outline: 2px solid white; } </style> </head> <body translate="no"> <img id="img" class="example" src="//repo.bfw.wiki/bfwrepo/image/6645cd63e0320.png" /> <svg style="display: none;"> <defs> <filter id="3d"> <feDisplacementMap id="displacement" in="turbulence" in2="SourceGraphic" scale="60" xChannelSelector="R" yChannelSelector="B" x="0%" y="0%" width="100%" height="100%" result="displacementMap"/> <feColorMatrix id="colorMatrix" type="hueRotate" values="10" in="displacementMap" result="colormatrix"/> </filter> </defs> </svg> <div class="footer"> <div class="text">Move the cursor over the image</div> <div class="buttons"> <button class="button-active">RR</button><button>RG</button><button>RB</button><bu.........完整代码请登录后点击上方下载按钮下载查看
网友评论0