css+js实现三维层叠照片切换效果代码
代码语言:html
所属分类:画廊相册
代码描述:css+js实现三维层叠照片切换效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200" rel="stylesheet"> <style> body { height: 100vh; background: palegoldenrod; } .gallery-container { position: relative; height: 100vh; width: 100vw; overflow: hidden; } .gallery { position: absolute; top: 50%; display: flex; align-items: center; justify-content: center; width: 100vw; height: 200px; -webkit-perspective: 800px; perspective: 800px; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-transform-origin: center center; transform-origin: center center; -webkit-transform: translateY(-50%); transform: translateY(-50%); } .frame { display: flex; flex-flow: column; align-items: center; justify-content: center; border: 2px solid white; border-radius: 4px; position: relative; height: 100%; width: 200px; background: white; -webkit-transform-style: preserve-3d; transform-style: preserve-3d; -webkit-transform-origin: center center; transform-origin: center center; cursor: pointer; overflow: hidden; background: radial-gradient(#cfaf7f, #6a4a0f); } .frame .image { display: block; position: relative; height: auto; width: 90%; pointer-events: none; } .frame .info { color: white; text-shadow: 0 0 2px rgba(0, 0, 0, 0.8); font-family: "Source Sans Pro", serif; font-size: 1.2em; } </style> </head> <body> <div class="gallery-container"> <div class="gallery"> <div class="frame"> <img class="image" src="//repo.bfw.wiki/bfwrepo/icon/5e83de11eb571.png"> <div class="info">Pumpernickel</div> </div> <div class="frame"> <img class="image" src="//repo.bfw.wiki/bfwrepo/icon/5e83e01e7154e.png"> <div class="info">Rye</div> </div> <div class="frame"> <img class="image" src="//repo.bfw.wiki/bfwrepo/icon/5e83e03407e19.png"> <div class="info">Wheat</div> </div> <div class="frame"> <img class="image" src="//repo.bfw.wiki/bfwrepo/image/606502f17d4a4.png"> <div class="info">Ciabatta</div> </div> <div class="frame"> <img class="image" src="//repo.bfw.wiki/bfwrepo/image/6065030ccad6e.png"> <div class="info">Baguette</div> </div> </div> </div> <script >var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}var $ = function $(selector) {return document.querySelector(selector);}; var $$ = function $$(selector) {return document.querySelectorAll(selector);}; var tick = 0; function lerp(n1, n2, speed) { return (1 - speed) * n1 + speed * n2; } function angle(from, to) { return Math.atan2( to[1] - from[1], to[0] - from[0]); } function distance(from, to) { return Math.sqrt( Math.pow(to[0] - from[0], 2), Math.pow(to[1] - from[1], 2)); } function distNorm(from, to, xMax, yMax) { return Math.sqrt( Math.pow((to[0] - from.........完整代码请登录后点击上方下载按钮下载查看
网友评论0