css实现三维玻璃弹珠球滚动动画效果代码

代码语言:html

所属分类:动画

代码描述:css实现三维玻璃弹珠球滚动动画效果代码

代码标签: css 三维 玻璃 弹珠 滚动 动画

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


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

<head>

  <meta charset="UTF-8">

  
  
  
<style>
html,
body {
  height: 100%;
  height: 100vh;
}

html {
  font-size: 10px;
  font-size: 0.8vw;
}

body {
  margin: 0;
  padding: 0;
  background: #f9f9f9;
  background: linear-gradient(0deg, #f9f9f9 0%, #9d9d9d 60%, gray 100%);
}

#area div {
  transform-style: preserve-3d;
}

#area {
  perspective-origin: 50% -50%;
  perspective: 500px;
  width: 100%;
  height: 100%;
  background-size: cover;
  display: grid;
  place-items: center;
}

.ball {
  position: relative;
  border-radius: 50%;
  width: 10rem;
  height: 10rem;
  background: transparent;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.ball::before,
.ball::after {
  content: "";
  border-radius: 50%;
  position: absolute;
}

.ball::before {
  z-index: 100;
  width: 10rem;
  height: 10rem;
  mix-blend-mode: screen;
  background: radial-gradient(circle at 10rem 2rem, #fff, #fff0 50%);
  background-size: 200%;
  background-position: 75%;
}

.ball::after {
  z-index: 101;
  width: 10rem;
  height: 10rem;
  mix-blend-mode: darken;
  background: radial-gradient(circle at 5rem 3.3rem, #23acc400, #23acc4aa);
}

.ball::oldafter {
  z-index: 101;
  top: 2%;
  left: 5%;
  width: 90%;
  height: 90%;
  background: radial-gradient(circle at 50% 0px, #ffffff, rgba(255, 255, 255, 0) 58%);
}

.ball .inner {
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  position: absolute;
  transform-style: preserve-3d;
}

.ball {
  animation: roll 10s ease-in-out alternate infinite;
}

.ball .inner {
  animation: inner-roll 10s ease-in-out alternate infinite;
}

.ball::before {
  animation: shine-move 10s ease-in-out alternate infinite;
}

.ball .shadow {
  animation: shadow-move 10s ease-in-out alternate infinite;
}

.ball .reflection {
  animation: shadow-move 10s ease-in-out alternate infinite;
}

.ball .shadow::after {
  animation: shadowAfter-move 10s ease-in-out alternate infinite;
}

.ball .glint {
  animation: glint-move 10s ease-in-out alternate infinite;
}

@keyframes roll {
  0% {
    transform: translate(-50rem);
  }
  100% {
    transform: translate(50rem);
  }
}
@keyframes inner-roll {
  0% {
    transform: rotate3d(0, 1, 1, 90deg) rotateZ(-572.4deg);
  }
  100% {
    transform: rotate3d(0, 1, 1, 90deg) rotateZ(572.4deg);
  }
}
@keyframes shine-move {
  0% {
    background-position: 25%;
  }
  100% {
    background-position: 75%;
  }
}
@keyframes shadow-move {
  0% {
    left: 1rem;
  }
  100% {
    left: 3.5rem;
  }
}
@keyframes shadowAfter-move {
  0% {
    left: -7.5rem;
  }
  100% {
    left: -2.5rem;
  }
}
@keyframes glint-move {
  0% {
    left: 6.75rem;
    width: 1rem;
    transform: rotate(-45deg);
  }
  50% {
    width: 1.75rem;
  }
  100% {
    left: 2.25rem;
    width: 1rem;
    transform: rotate(45deg);
  }
}
.ball .disc {
  position: absolute;
  border-radius: 50%;
  width: 10rem;
  height: 10rem;
  background: white;
  opacity: 0.3;
  transform-style: preserve-3d;
}

.disc:nth-child(1) {
  transform: rotateY(0deg);
}

.disc:nth-child(2) {
  transform: rotateY(30deg);
}

.disc:nth-child(3) {
  transform: rotateY(60deg);
}

.disc:nth-child(4) {
  transform: rotateY(90deg);
}

.disc:nth-child(5) {
  transform: rotateY(120deg);
}

.disc:nth-child(6) {
  transform: rotateY(150deg);
}

.disc:nth-child(7) {
  transform: rotateY(180deg);
}

.ball .glint {
  position: absolute;
  width: 1rem;
  height: 2rem;
  top: 0.7rem;
  left: 6.75rem;
  z-index: 200;
  transform: rotate(-45deg);
  background: white;
  opacity: 0.8;
  filter: blur(1px);
  border-radius: 50%;
}

.ball .shadow {
  width: 5rem;
  height: 5rem;
  top: 7.5rem;
  left: 1rem;
  border-radius: 50%;
  transform-style: preserve-3d;
  position: absolute;
  background: black;
  transform: rotateX(80deg);
  filter: blur(10px);
  opacity: 0.3;
  z-index: -2;
}

.ball .shadow::after {
  position: absolute;
  content: "";
  left: -7.5rem;
  top: -11rem;
  width: 15rem;
  height: 15rem;
  background: black;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0) 100%);
  opacity: 1;
  border-radius: 50%;
}

.ball .reflection {
  position: absolute;
  top: 6.5rem;
  left: 1rem;
  width: 6rem;
  height: 6rem;
  background: white;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, white 90%);
  opacity: 1;
  border-radius: 50%;
  transform: rotateX(80deg);
  filter: blur(10px);
  z-index: -1;
}

@keyframes rotate {
  100% {
    transform: rotateX(360deg) rotateY(-360deg);
  }
}
@keyframes rotateRev {
  100% {
    transform: rotateX(-360deg) rotateY(-360deg);
  }
}
.marble div:nth-child(1) {
  transform: rotateX(0deg) rotateZ(15deg);
}

.marble div:nth-child(2) {
  transform: rotateX(30deg) rotateZ(15deg);
}

.marble div:nth-child(3) {
  transform: rotateX(60deg) rotateZ(15deg);
}

.marble div:nth-child(4) {
  transform: rotateX(90deg) rotateZ(15deg);
}

.marble div:nth-child(5) {
  transform: rotateX(120deg) rotateZ(15deg);
}

.marble div:nth-child(6) {
  transform: rotateX(150deg) rotateZ(15deg);
}

.marble div:nth-child(7) {
  transform: rotateX(180deg) rotateZ(15deg);
}

.test {
  position: absolute;
  top: 0;
  left: 0;
  width: 10rem;
  height: 10rem;
  background: white;
  background: radial-gradient(50% 35%, #ffbe40 48%, transparent 52%) no-repeat;
  background-position: -3rem -0.3rem;
}

.disc.fleck1 {
  opacity: 0.8;
  background: url("data:image/svg+xml,%3C?xml version='1.0' encoding='UTF-8'?%3E %3Csvg width='360px' height='360px' viewBox='0 0 360 360' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Ctitle%3EArtboard%3C/title%3E %3Cg id='Artboard' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cpath d='M154.515625,-22.6364965 C120.489583,-2.36305903 113.229167,31.9611597 132.734375,80.3361597 C161.992188,152.89866 188.203125,164.750222 171.359375,206.488503 C154.515625,248.226785 56.7421875,352.508035 111.4375,419.781472 C147.901042,464.630431 194.808594,458.975483 252.160156,402.816628 L171.359375,381.718972 C271.414063,347.132571 317.636719,291.062143 310.027344,213.507687 C298.613281,97.1760035 196.273438,100.097656 187.710937,49.9960937 C179.148437,-0.10546875 202.582031,-39.8396215 232.855469,-57.5427465 C253.03776,-69.3448299 226.924479,-57.7094132 154.515625,-22.6364965 Z' id='Path-2' fill='%2300B4B5'%3E%3C/path%3E %3Cpath d='M127.515625,-14.9414063 C93.4895833,5.33203125 86.2291667,39.65625 105.734375,88.03125 C134.992188,160.59375 161.203125,172.445312 144.359375,214.183594 C127.515625,255.921875 10.6484375,334.332031 84.4375,427.476562 C133.630208,489.572917 180.53776,483.917969 225.160156,410.511719 L144.359375,389.414062 C244.414062,354.827661 290.636719,298.757233 283.027344,221.202777 C271.613281,104.871094 184.430866,99.65625 175.868366,49.5546875 C167.305866,-0.546875 175.582031,-32.1445313 205.855469,-49.8476563 C226.03776,-61.6497396 199.924479,-50.0143229 127.515625,-14.9414063 Z' id='Path-2' fill='%2300D3D7'%3E%3C/path%3E %3C/g%3E %3C/svg%3E");
  background-size: cover;
}

.disc.fleck2 {
  opacity: 0.8;
  background: url("data:image/svg+xml,%3C?xml version='1.0' encoding='UTF-8'?%3E %3Csvg width='360px' height='360px' viewBox='0 0 360 360' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Ctitle%3Efleck2%3C/title%3E %3Cg id='fleck2' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cpath d='M92.1328125,-15.109375 C115.554688,-7.63541667 127.265625,15.1210938 127.265625,53.1601562 C127.265625,110.21875 85.0878906,138.079842 92.1328125,193.825935 C99.1777344,249.572029 199.382813,316.402344 174.160156,386.109375 C157.345052,432.580729 168.592448,446.526042 207.902344,427.945313 C235.667969,374.179688 242.609375,328.167969 228.726563,289.910156 C207.902344,232.523437 137.617188,224.414062 160,163.78125 C182.382813,103.148437 174.292969,1.10546875 153.484375,-15.109375 C139.611979,-25.9192708 119.161458,-25.9192708 92.1328125,-15.109375 Z' id='Path-3' fill='%23FF6F56'%3E%3C/path%3E %3Cpath d='M112.132812,-15.109375 C128.757813,-6.63020833 137.070313,16.6289063 137.070312,54.6679688 C137.070312,111.726562 117.746094,124.253906 124.791016,180 C131.835937,235.746094 219.382812,316.402344 194.160156,386.109375 C177.345052,432.580729 188.592448,446.526042 227.902344,427.945313 C255.667969,374.179688 262.609375,328.167969 248.726563,289.910156 C227.902344,232.523437 157.617187,224.414063 180,163.78125 C202.382812,103.148438 194.292969,1.10546875 173.484375,-15.109375 C159.611979,-25.9192708 139.161458,-25.9192708 112.132812,-15.109375 Z' id='Path-3' fill='%23FF4149'%3E%3C/path%3E %3C/g%3E %3C/svg%3E");
  background-size: cover;
}

.disc.fleck3 {
  opacity: 0.8;
  background: url("data:image/svg+xml,%3C?xml version='1.0' encoding='UTF-8'?%3E %3Csvg width='360px' height='360px' viewBox='0 0 360 360' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Ctitle%3Efleck3%3C/title%3E %3Cg id='fleck3' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cpath d='M109.662243,-14.0390625 C116.238977,14.4557292 116.829427,38.8216146 111.433594,59.0585938 C103.339844,89.4140625 58.9453125,189.210938 85.5507812,226.773438 C112.15625,264.335938 237.132812,313.601563 224.421875,389.652344 C215.947917,440.352865 226.835938,440.352865 257.085938,389.652344 C306.265625,359.498698 306.265625,328.183594 257.085938,295.707031 C183.316406,246.992188 128,253.398438 145,180 C162,106.601563 265.179688,19.5234375 246.375,-5.73046875 C233.838542,-22.5664062 188.267623,-25.3359375 109.662243,-14.0390625 Z' id='Path-4' fill='%2372FB00'%3E%3C/path%3E %3Cpath d.........完整代码请登录后点击上方下载按钮下载查看

网友评论0