gsap实现图片过渡方块切片效果代码
代码语言:html
所属分类:其他
代码描述:gsap实现图片过渡方块切片效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { height: 100vh; display: flex; justify-content: center; align-items: center; margin: 0; } .squares { position: relative; z-index: 1; width: min(90vw, 90vh); height: min(90vw, 90vh); overflow: hidden; cursor: pointer; } .squares .item { position: absolute; z-index: 1; width: 100%; height: 100%; } .squares .item img { -o-object-fit: cover; object-fit: cover; width: 100%; height: 100%; } .squares .squares { position: absolute; z-index: 100; width: 100%; height: 100%; } .squares .square { position: absolute; z-index: 1; width: calc(var(--size) * 1px); height: calc(var(--size) * 1px); transform: translate(calc(var(--x) * 1px), calc(var(--y) * 1px)); } .squares .square .s { pointer-events: none; background-image: url(//repo.bfw.wiki/bfwrepo/image/5fb34aff14a0f.png); background-size: calc(var(--width) * 1px) calc(var(--height) * 1px); background-position: calc(var(--x) * -1px) calc(var(--y) * -1px); height: 100%; } </style> </head> <body > <!-- Follow me on Instagram: https://www.instagram.com/supahfunk/ Twitter: https://twitter.com/supahfunk Codepen: https://codepen.io/supah/ --> <div class="squares"> <div class="item"> <img src="//repo.bfw.wiki/bfwrepo/image/5e62ef20b92ee.png" /> </div> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.10.1.js"></script> <script > class Squares { constructor(obj) { Object.assign(this, obj) this.wrapper = document.querySelector(obj.wrapper) this.init() } init() { this.squares = document.createElement('div') this.squares.classList.add('squares') this.wrapper.appendChild(this.squares) this.f.........完整代码请登录后点击上方下载按钮下载查看
网友评论0