js+div实现照片相册堆叠文字描述效果代码

代码语言:html

所属分类:动画

代码描述:js+div实现照片相册堆叠文字描述效果代码

代码标签: js div 照片 相册 堆叠 文字 描述

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">



    <style>
        :root {
          --bgc: #202124;
          --fgc: #fff;
          --time: 3s;
          --ease: cubic-bezier(.3, .7, 0, 1);
          --ease2: cubic-bezier(.3, .7, .2, 2);
          font-family: Inter, sans-serif;
          background: var(--bgc);
          color: var(--fgc);
          overflow: hidden;
          font-size: 2.3vmin;
        }
        
        .container {
          position: relative;
          height: 100vh;
        }
        
        .color, .d {
          text-decoration: none;
          width: 30vmin;
          --bg: var(--fgc);
          background: var(--bg);
          color: var(--bgc);
          display: flex;
          flex-direction: column;
          padding: 2vmin;
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translateY(-50%) translateX(-50%);
          -webkit-animation: var(--time) goDown var(--ease);
                  animation: var(--time) goDown var(--ease);
          -webkit-animation-fill-mode: forwards;
                  animation-fill-mode: forwards;
          animation-count: 1;
          opacity: 1;
          transition: 300ms opacity;
        }
        .color.remove, .d.remove {
          opacity: 0;
        }
        .color::after, .d::after {
          content: "";
          position: absolute;
          z-index: -1;
          inset: 0;
          background: var(--bg);
        }
        .color::before, .d::before {
          content: "";
          position: absolute;
          z-index: -2;
          inset: -2vmin;
          background: var(--color);
          -webkit-animation: var(--time) expand var(--ease);
                  animation: var(--time) expand var(--ease);
          -webkit-animation-fill-mode: forwards;
                  animation-fill-mode: forwards;
          animation-count: 1;
        }
        
        .color__swatch {
          order: 1;
          aspect-ratio: 1;
          background: var(--color);
        }
        
        .color__bottom {
          order: 2;
        }
        
        .color__value,
        .color__name {
          display: block;
          line-height: 0.9;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        
        .color__name {
          display: inline-block;
          padding-top: 1.9vmin;
          padding-bottom: 0.9vmin;
          font-size: 1.4rem;
          font-weight: 900;
          --id: calc(var(--time) * 0.2);
        }
        .color__name--verylong {
          font-size: 1rem;
        }
        .color__name--long {
          font-size: 1.15rem;
        }
        .color__name i {
          --top: 1.1;
          position: relative;
          opacity: 0;
          transform: translate(0, 100%);
          -webkit-animation: calc(var(--time) * .3) jumpin var(--ease2);
                  animation: calc(var(--time) * .3) jumpin var(--ease2);
          -webkit-animation-delay: calc(var(--id) + var(--i) * calc(var(--time) * 0.2));
                  animation-delay: calc(var(--id) + var(--i) * calc(var(--time) * 0.2));
          -webkit-animation-fill-mode: forwards;
                  animation-fill-mode: forwards;
          animation-count: 1;
        }
        .color__name i.heavy {
          --top: .5;
        }
        
        .color__value {
          font-size: 0.9rem;
          font-weight: 400;
          -webkit-clip-path: inset(0 0 100% 0);
                  clip-path: inset(0 0 100% 0);
          -webkit-animation: calc(var(--time) * .6) open var(--ease);
                  animation: calc(var(--time) * .6) open var(--ease);
          -webkit-animation-fill-mode: forwards;
                  animation-fill-mode: forwards;
          animation-count: 1;
          width: 100%;
          overflow: hidden;
          -webkit-animation-delay: calc(var(--time) * 0.35);
                  animation-delay: calc(var(--time) * 0.35);
          -webkit-animation-duration: calc(var(--time) * .2);
                  animation-duration: calc(var(--time) * .2);
          letter-spacing: 0.02em;
        }
        
        @-webkit-keyframes jumpin {
          0% {
            opacity: 0;
            top: calc(1.2em * var(--top));
            color: var(--fgc);
          }
          40% {
            color: var(--color);
          }
          100% {
            opacity: 1;
            top: 0;
          }
        }
        
        @keyframes jumpin {
          0% {
            opacity: 0;
            top: calc(1.2em * var(--top));
            color: var(--fgc);
          }
          40% {
            color: var(--color);
          }
          100% {
            opacity: 1;
            top: 0;
          }
        }
        @-webkit-keyframes goDown {
          0% {
            opacity: 0;
            transform: translate(calc(var(--rnd2) * 400%), calc(var(--rnd4) * 400%)) scale(3) rotate(calc(var(--rnd2) * -90deg));
          }
          40% {
            opacity: 1;
          }
          100% {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1) rotate(calc(var(--rnd) * 20deg)) translate(calc(var(--rnd3) * 50%), calc(var(--rnd4) * 50%));
    .........完整代码请登录后点击上方下载按钮下载查看

网友评论0