div+css实现三维立体手机立体城市建筑生长效果代码

代码语言:html

所属分类:其他

代码描述:div+css实现三维立体手机立体城市建筑生长效果代码

代码标签: div css 三维 立体 手机 立体 城市 建筑 生长

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

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

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

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  perspective: 200vmin;
  background: #484cef;
}

@keyframes blink {
  0%, 6%, 100% { background-color: var(--c4); }
  1%, 5% { background-color: var(--c3); }
}

@keyframes bounceMarker {
  0%, 100% { transform: translateZ(0); }
  50% { transform: translateZ(0.5em); }
}

@keyframes light {
  25% { box-shadow: 0 0 2em 1em var(--c3); }
  0%, 50%, 100% { box-shadow: 0 0 0 0 var(--c3); }
}

.phone {
  --c0: #141643;
  --c1: #484cef;
  --c2: #fffcdd;
  --c3: #f80;
  --c4: #ffea3b;
  --c5: #00a3f9;
  --t: 1s;
  font-size: 1vmin;10px;
  width: 30em;
  aspect-ratio: 67 / 138;
  color: var(--c0);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate3d(0, 0, 0, 90deg) rotate(0deg);
  transform-style: preserve-3d;
  transition: transform var(--t);
  atransform: translate(-50%, -50%) rotate3d(1, 0.65, -1, 90deg) rotate(30deg);
  pointer-events: none;

  &:has(input:checked) {
    transform: translate(-50%, -50%) rotate3d(0.7, 0.5, -1, 90deg) rotate(30deg);
    .shadow {
      transform: translate3d(-5em, 1em, -4em) scale(1.025);
      width: calc(100% + 4em);
    }
    .frame {
      box-shadow: -0.25em 0.25em var(--c1);

      &::before {
        border-radius: 4em 2em 2em 2em;
      }

      .main-button {
        box-shadow:  -0.25em 0.25em 0 0 var(--c1);
        background-position: 0em 0;
      }
      .screen {
        box-shadow: inset -0.5em 0.5em var(--c1);

        .building {
          box-shadow: 
            inset 0 0 0 0.5em var(--c2),
            inset -0.8em 0 var(--c0),
            inset 0 0.8em var(--c1);
          transform: translate(-50%, -50%) translateZ(var(--d));
          transition-delay: var(--s);

          .side {
            transform: translate(-50%, -50%) translateZ(var(--dt)) scale(1.2);
            transition-delay: calc(var(--s) + 0.5s);
          }

          .antenna {
            transform: translate(-50%, -50%) translateZ(3.75em);
            transition-delay: calc(var(--s) + 2s);
          }
        }

        .building-shadow {
          transform: translate(-50%, -50%) scale(1.7, 1.4);
          transition-delay: var(--s);
          transform-origin: 100% 50%;

          &.building-shadow-3 {
            transform: translate(-50%, -50%) scale(1.6, 1.6);
          }
        }

        .marker-container {
          animation: bounceMarker 2s infinite;
          animation-delay: calc(var(--t) * 2);

          .marker {
            transform: rotate(45deg) rotate3d(-1, 1, 0, 90deg);
            transition-delay: var(--t);
            transition-timing-function: cubic-bezier(0.75, 0, 0.5, 1.5);
            box-shadow: -0.45em 0.1em var(--c4);
          }
        }

        .start-button {
          opacity: 0;
          transition-delay: 0s;
          pointer-events: none;
        }

        .close-button {
          opacity: 1;
          transition-delay: calc(var(--t) / 2);
          pointer-events: auto;
        }

        .trees {
          .tree {
            box-shadow: -0.5em 0 var(--c0);
            transition-delay: calc(var(--t) * 8);
            
            &::before, &::after {
              transform:translate(-50%, -50%) translateZ(var(--d));
              transition-delay: calc(var(--t) * 8);
            }
          }
        }
        .dots {
          .dot {
            animation-name: blink;

            &::before, &::after {
              transition-duration: var(--t);
              transition-delay: calc(var(--t) * 2.25);
            }
            &::before { transform: translateZ(0.15em); }
            &::after { transform: translateZ(0.30em); }
          }
        }
      }
    }
  }

  & * {
    &, &::before, &::after {
      position: absolute;
      box-sizing: border-box;
      transform-style: preserve-3d;
    }
  }

  & input {
    width: 1px;
    height: 1px;
    overflow: clip;
    clip-path: polygon(0 0, 1px 1px);
  }

  .shadow {
    width: 100%;
    height: 100%;
    background: radial-gradient(farthest-side circle, var(--c0) 50%, #0000 0) 50% 50% / 0.5em 0.5em;
    border-radius: 4em;
    -webkit-mask: linear-gradient(90deg, #0000, #000 5em);
    transform: translate3d(0, 0, -4em) scale(1);
    transition: transform var(--t), width var(--t);
  }

  .frame {
    width: 100%;
    height: 100%;
    background: 
      radial-gradient(circle at 50% 5%, var(--c1) 0.5em, #0000 0.6em),
      var(--c0);
    border-radius: 3em;
    transition: box-shadow var(--t);
    box-shadow: 0 0 var(--c1);

    &::before {
      content: "";
      width: 100%;
      height: 100%;
      transform: translateZ(-4em);
      background: var(--c0);
      border-radius: 4em 2em 2em 3em;
      transition: border-radius var(--t);
    }

    .screen {
      aspect-ratio: 75 / 133;
      width: 90%;
      background: red;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      box-shadow: inset 0 0 var(--c1);
      transition: box-shadow var(--t);
      background:
        linear-gradient(var(--c1) 0 0) 9.5% 6% / 30% 27%,
        linear-gradient(var(--c5) 0 0) 90% 6% / 35% 27%,
        linear-gradient(var(--c1) 0 0) 9.5% 50% / 30% 14%,
        linear-gradient(var(--c1) 0 0) 90% 50% / 35% 14%,
        linear-gradient(var(--c1) 0 0) 5% 94.5% / 8% 27%,
        linear-gradient(var(--c1) 0 0) 33.5% 94.5% / 8% 27%,
        linear-gradient(var(--c1) 0 0) 90% 94.5% / 35% 27%,
        linear-gradient(#0000 35%, var(--c0) 0 40%, #0000 0 60%, var(--c0) 0 65%, #0000 0),
        linear-gradient(90deg, #0000 43%, var(--c0) 0 52%, #0000 0),
        linear-gradient(90deg, #0000 17.5%, var(--c0) 0 26.5%, #0000 0) 0 100% / 100% 40%,
        var(--c2);
      background-repeat: no-repeat;

      .marker-container {
        width: 100%;
        height: 100%;

        .marker {
          width: 5em;
          height: 5em;
          background: radial-gradient(farthest-side circle, var(--c4) 35%, var(--c3) 0);
          border-radius: 100% 100% 0 100%;
          transform-origin: 100% 100%;
          transform: rotate(45deg) rotate3d(0, 0, 0, 0deg);
          top: 27%;
          left: 60%;
          transition: transform, box-shadow;
          transition-duration: var(--t);
          transition-delay: 0s;
          box-shadow: 0 0 var(--c4)
        }
      }

      .start-button {
        width: 90%;
        background: #293;
        color: #fff;
        padding: 1em;
        text-align: center;
        font-size: 1.5em;
        border-radius: 1.5em;
        left: 50%;
        bottom: 0;
        transform: translate(-50%, -25%);
        font-family: Helvetica, Arial, sans-serif;
        font-weight: 400;
        text-transform: uppercase;
        transition: opacity calc(var(--t) / 4);
        transition-delay: calc(var(--t) / 2);
        pointer-events: auto;
      }

      .close-button {
        width: 4.5em;
        height: 4.5em;
        background: 
          linear-gradient(#fff 0 0) 50% 50% / 2em 0.25em,
          linear-gradient(#fff 0 0) 50% 50% / 0.25em 2em,
          #0008;
        color: #fff;
        text-align: center;
        border-radius: 50%;
        right: 0;
        bottom: 0;
        transform: translate(-25%, -25%) rotate(45deg);
        background-repeat: no-repeat;
        text-indent: -100in;
        overflow: clip;
        opacity: 0;
        transition: opacity calc(var(--t) / 4);
        transition-delay: 0s;
        pointer-events: none;
      }

      .building, .building-shadow {
        width: var(--w);
        height: var(--h);
        background: var(--c2);
        box-shadow: 
          inset 0 0 0 0.5em var(--c2),
          inset 0 0 var(--c0),
          inset 0 0 var(--c1);
        transform: translate(-50%, -50%) translateZ(0);
        transition: box-shadow, transform;
        transition-duration: var(--t);

        &.building-shadow {
          box-shadow: none;
          background: var(--c0);
          transform-origin: 95% 50%;
          transform: translate(-50%, -50%) scale(0.6);

          &::before, &::after { content: none !important; }
        }

        .side {
          width: 100%;
          height: 100%;
          top: 50%;
          left: 50%;
          background: var(--c2);
          transition: transform var(--t);
          transition-delay: 0s;
          transition-timing-function: cubic-bezier(0.75, 0, 0.5, 1.5);
        }

        &::before,
        & .side::before {
          content: "";
          width: var(--w);
          height: var(--d);
          top: 100%;
          transform-origin: 50% 0%;
          transform: rotateX(-90deg);
          background-repeat: no-repeat;
        }

        &::after,
        & .side::after {
          content: "";
          height: var(--h);
          width: var(--d);
          transform-origin: 0 50%;
          transform: rotateY(90deg);
          background-repeat: no-repeat;
        }

        &.building-1, &.building-shadow-1 {
          --w: 3.5em;
          --h: 3.5em;
          --d: 10em;
          --s: calc(var(--t) * 3);
          top: 81%;
          left: 80%;
          transition-delay: 0s;

          &::before {
            background: 
              linear-gradient(var(--c0) 0 0) 0 0 / 100% 0.5em no-repeat,
              linear-gradient(var(--c1) 0 0) 0 9em / 100% 1em no-repeat,
              repeating-linear-gradient(var(--c0) 0 0.25em, var(--c1) 0 1.35em);
          }

          &::after {
            background: 
              linear-gradient(var(--c0) 0 0) 0 0 / 0.5em 100% no-repeat,
              linear-gradient(var(--c0) 0 0) 8.3em 50% / 2em 40% no-repeat,
              linear-gradient(var(--c1) 0 0) 8.3em 50% / 2em 50% no-repeat,
              linear-gradient(var(--c1) 0 0) 9.75em 50% / 0.5em 100% no-repeat,
              linear-gradient(var(--c0) 0 0) 9em 0 / 1em 100% no-repeat,
              repeating-linear-gradient(90deg, var(--c1) 0 0.25em, var(--c0) 0 1.35em);
          }
        }

        &.building-2, &.building-shadow-2 {
          --w: 5em;
          --h: 5em;
          --d: 13em;
          --s: calc(var(--t) * 5.75);
          top: 17%;
          left: 82%;
          transition-delay: 0s;

          &::before {
            background: 
              linear-gradient(var(--c5) 0 0) 0 12.75em / 100% 0.5em no-repeat,
              repeating-linear-gradient(90deg, #0000 0 10%, var(--c2) 0 45%) 0 10em / 100% 3em no-repeat,
              var(--c5);
          }

          &::after {
            background: 
              linear-gradient(var(--c0) 0 0) 12.75em 0  /  0.5em 100% no-repeat,
              repeating-linear-gradient(#0000 0 10%,  var(--c2) 0 45%)  10em 0 / 3em 100% no-repeat,
              var(--c0)
          }

          .antenna {
            --w: 0.35em;
            --h: 0.35em;
            --d: 5em;
            left: 42.5%;
            top: 57.5%;
            transform: translate(-50%, -50%) translateZ(-0.5em);
            width: var(--w);
            height: var(--h);
            background: var(--c3);
            box-shadow: 0 0 0em 0em var(--c3);
            animation: light 3s infinite;
            animation-delay: calc(var(--s) + 2s);
            transition: transform var(--t);
            transition-delay: 0s;

            &::before {
              content: "";
              width: var(--w);
              height: var(--d);
              top: 100%;
              transform-origin: 50% 0%;
              transform: rotateX(-90deg);
              background: var(--c5);

            }

            &::after{
              content: .........完整代码请登录后点击上方下载按钮下载查看

网友评论0