gsap+css实现带镜面反射的三维卡片翻转动画效果代码

代码语言:html

所属分类:动画

代码描述:gsap+css实现带镜面反射的三维卡片翻转动画效果代码

代码标签: gsap css 镜面 反射 三维 卡片 翻转 动画

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

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

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

  
  
  
<style>

html {
  --zoom: 120;
  --green: #37996b;
  --neon: #3ecf8e;
}
:root {
  --unit: 1vmin;
  --available-screen-min: 665;
  --px: calc(var(--zoom) * (var(--unit) / var(--available-screen-min)));
  --bg: #060809;
  --logopng: url(//repo.bfw.wiki/bfwrepo/icon/63e331210762f.png);
  --ticket: url(//repo.bfw.wiki/bfwrepo/svg/ticket-shape.svg);
  --ar: 10/30;
  --gutter: 8%;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
}
*::after,
*::before {
  content: "";
  display: block;
  position: relative;
  box-sizing: border-box;
}
head::before,
head::after,
body::before,
body::after,
html::before,
html::after {
  content: "";
  position: absolute;
  background-repeat: no-repeat;
  box-sizing: border-box;
  filter: blur(0);
}
body {
  all: unset;
  background-color: var(--bg);
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
a {
  all: unset;
}

#app {
  perspective: 1200px;
  --o: 0;
  --p: 100%;
  --h: 50%;
  --r: 0;
  transform: translate3d(0, 0, 0.1px);
}

.ticket {
  --scale: 1;
  transform: translate3d(0, 0, 0.1px) scale(var(--scale)) rotateY(var(--r));
  transform-style: preserve-3d;
  pointer-events: auto;
}

.front,
.back {
  grid-area: 1/1;
  background-color: #6e6176;
  background-image: radial-gradient(
    circle at var(--p) 50%,
    #111 10%,
    transparent 100%
  );
  background-size: 100% 220vh;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 15px;
  display: grid;
  backface-visibility: visible;
  transform: translateZ(1px);
  transform-style: preserve-3d;
  mask-image: var(--ticket);
  mask-size: cover;
  mask-repeat: no-repeat;
  height: calc(420 * var(--px));
}
.cutout {
  position: absolute;
}

.front::after,
.back::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
    -70deg,
    transparent 40%,
    rgba(255, 255, 255, 0.5) 40.5%,
    transparent
  );
  background-size: 200% 200%;
  background-position: var(--p) var(--p);
  z-index: 5;
  opacity: calc(var(--o) + 0.5);
  pointer-events: none;
}

.front {
  transform: rotateY(180deg) translateZ(1px);
}
.back {
  padding: calc(20 * var(--px));
}

.holo {
  display: block;
  position: absolute;
  inset: 0;
  border-radius: 15px;
}

.holo {
  --space: 5%;
  --red: hsl(0, 100%, 50%);
  --orange: hsl(30, 100%, 50%);
  --yellow: hsl(60, 100%, 50%);
  --green: hsl(120, 100%, 50%);
  --cyan: hsl(180, 100%, 50%);
  --blue: hsl(222, 100%, 50%);
  --purple: hsl(258, 100%, 50%);
  --magenta: hsl(300, 100%, 50%);
  background-image: repeating-linear-gradient(
    -45deg,
    var(--red) 0%,
    var(--orange) calc(var(--space) * 1),
    var(--yellow) calc(var(--space) * 2),
    var(--green) calc(var(--space) * 3),
    var(--cyan) calc(var(--space) * 4),
    var(--blue) calc(var(--space) * 5),
    var(--purple) calc(var(--space) * 6),
    var(--magenta) calc(var(--space) * 7),
    var(--red) calc(var(--space) * 8)
  );
  background-size: 150vw 150vh;
  background-position: calc(var(--h)) calc(var(--h));
  background-repeat: no-repeat;
  mask-image: var(--logopng);
  mask-size: 80% 80%;
  mask-repeat: no-repeat;
  mask-position: 150% 180%;
  mix-blend-mode: plus-lighter;
  filter: brightness(0.9) contrast(0.7) saturate(2);
  opacity: var(--o);
}

.logo {
  width: 50%;
  place-self: center;
  transform: translateY(-14%);
}

.divider {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: start;
  bottom: 2%;
  left: 0;
  right: 0;
  height: 18%;
  padding: 0 var(--gutter);
  text-transform: uppercase;

  background-image: repeating-linear-gradient(
      90deg,
      #fff0 0px,
      #fff0 8px,
      var(--green) 8px,
   .........完整代码请登录后点击上方下载按钮下载查看

网友评论0