js+css实现图片相册堆叠点击更换位置合并效果代码

代码语言:html

所属分类:画廊相册

代码描述:js+css实现图片相册堆叠点击更换位置合并效果代码

代码标签: js css 图片 相册 堆叠 点击 更换 位置 合并

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">

  
  
<style>
body {
  padding: 0;
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: black;
  font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
  overflow: hidden;
}
.gallery {
  position: relative;
  perspective: 1500px;
  transform-style: preserve-3d;
  width: 200px;
  aspect-ratio: 1;
  background: silver;
  transform: rotate(45deg);
}
.gallery .image {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 4px solid white;
  box-sizing: border-box;
  transition: 1s ease;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: calc(var(--total) - var(--i));
	overflow: hidden;
}
.gallery .image img {
	--rotate: rotate(-45deg);
  transform: var(--rotate);
	transition: .3s ease;
}
.gallery .image:nth-of-type(odd) {
  --hovermove: -100px, 100px;
  --translate: calc((var(--i) - 1) * -70px), calc((var(--i) - 1) * 70px);
  --tZ: calc((var(--i) - 1) * -350px);
  animation: deploy 1.5s ease forwards;
} 
.gallery .image:nth-of-type(even) {
  --hovermove: 100px, -100px;
  --translate: calc(var(--i) * 70px), calc(var(--i) * -70px);
  --tZ: calc(var(--i) * -350px);
  animation: deploy 1.5s ease forwards;
}
.gallery .image:hover img,
.gallery .image.only-hover img {
	transform: var(--rotate) scale(1.1);
}
.gallery .image.only-hover{
  animation: clickAnimation 1s ease;
  z-index: 9;
}
.gallery.hidden-gallery .image {
  animation: close 1.5s ease forwards;
}
@keyframes deploy {
  from {
    transform: translate(0px, 0px) translateZ(0px);
  }
  to {
    transform: translate(var(--translate)) translateZ(var(--tZ));
  }
}
@keyframes close {
  from {
    transform: translate(var(--translate)) translateZ(var(--tZ));
  }
  to {
    transform: translate(0px, 0px) translateZ(0px);
  }
}
@keyframes clickAnimation {
  0% {
    transform: translate(var(--translate)) translateZ(var(--tZ));
  }
  20% {
    transform: translate(var(--hovermove)) translateZ(0px);
  }
  100% {
 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0