gsap+ScrollTrigger+svg实现页面滚动火箭发射升空动画效果代码

代码语言:html

所属分类:加载滚动

代码描述:gsap+ScrollTrigger+svg实现页面滚动火箭发射升空动画效果代码,鼠标往下滚动页面试试。

代码标签: gsap ScrollTrigger svg 页面 滚动 火箭 发射 升空 动画

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

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

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


  
  
<style>
:root {
  --color: #fff;
  --background-color: #000;
}

* {
  margin: 0;
  padding: 0;
}

@keyframes animateStars {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(0, 100vh, 0);
  }
}
body {
  overflow-x: hidden;
  min-height: 100%;
  background-color: var(--background-color);
  color: var(--color);
  font-family: -apple-system, Arial, sans-serif;
}

.stratosphere,
.instructions,
.artwork,
.stars {
  visibility: hidden;
  position: fixed;
}

.stratosphere {
  left: -300vw;
  right: -300vw;
  top: 0;
  bottom: 0;
  background-image: radial-gradient(ellipse at bottom, rgba(61, 101, 242, 0.25), rgba(0, 0, 0, 0) 35%);
}

.instructions {
  font-size: clamp(2.5em, 5vw, 5em);
  z-index: 1;
  font-weight: normal;
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
  left: 1em;
  bottom: 1em;
}
.instructions__notice {
  font-size: 0.35em;
  opacity: 0.3;
}

.scroller {
  max-height: 100vh;
  position: relative;
  overflow: auto;
  z-index: 1;
}
.scroller__panel {
  height: 100vh;
}
.scroller__panel:last-child {
  height: 200vh;
}

.artwork,
.stars {
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.stars--animated .stars__rear,
.stars--animated .stars__center {
  animation-name: animateStars;
}
.stars__star, .stars__star::after {
  position: absolute;
  background-color: white;
  border-radius: 50%;
  width: 1px;
  height: 1px;
}
.stars__star::after {
  content: "";
  display: block;
  margin-top: -100vh;
}
.stars__rear, .stars__center, .stars__front {
  position: absolute;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  animation: linear infinite;
}
.stars__rear .stars__star:nth-of-type(1) {
  top: 7vh;
  left: 59vw;
  opacity: 0.89;
}
.stars__rear .stars__star:nth-of-type(2) {
  top: 23vh;
  left: 67vw;
  opacity: 0.74;
}
.stars__rear .stars__star:nth-of-type(3) {
  top: 63vh;
  left: 26vw;
  opacity: 0.85;
}
.stars__rear .stars__star:nth-of-type(4) {
  top: 46vh;
  left: 88vw;
  opacity: 0.33;
}
.stars__rear .stars__star:nth-of-type(5) {
  top: 3vh;
  left: 19vw;
  opacity: 0.84;
}
.stars__rear .stars__star:nth-of-type(6) {
  top: 68vh;
  left: 45vw;
  opacity: 0.29;
}
.stars__rear .stars__star:nth-of-type(7) {
  top: 71vh;
  left: 35vw;
  opacity: 0.14;
}
.stars__rear .stars__star:nth-of-type(8) {
  top: 56vh;
  left: 34vw;
  opacity: 0.3;
}
.stars__rear .stars__star:nth-of-type(9) {
  top: 29vh;
  left: 56vw;
  opacity: 0.33;
}
.stars__rear .stars__star:nth-of-type(10) {
  top: 91vh;
  left: 8vw;
  opacity: 1.06;
}
.stars__rear .stars__star:nth-of-type(11) {
  top: 92vh;
  left: 69vw;
  opacity: 0.12;
}
.stars__rear .stars__star:nth-of-type(12) {
  top: 16vh;
  left: 99vw;
  opacity: 0.44;
}
.stars__rear .stars__star:nth-of-type(13) {
  top: 82vh;
  left: 74vw;
  opacity: 0.21;
}
.stars__rear .stars__star:nth-of-type(14) {
  top: 81vh;
  left: 78vw;
  opacity: 0.84;
}
.stars__rear .stars__star:nth-of-type(15) {
  top: 98vh;
  left: 7vw;
  opacity: 0.34;
}
.stars__rear .stars__star:nth-of-type(16) {
  top: 54vh;
  left: 64vw;
  opacity: 0.63;
}
.stars__rear .stars__star:nth-of-type(17) {
  top: 69vh;
  left: 84vw;
  opacity: 0.78;
}
.stars__rear .stars__star:nth-of-type(18) {
  top: 26vh;
  left: 64vw;
  opacity: 0.73;
}
.stars__rear .stars__star:nth-of-type(19) {
  top: 9vh;
  left: 96vw;
  opacity: 0.96;
}
.stars__rear .stars__star:nth-of-type(20) {
  top: 68vh;
  left: 14vw;
  opacity: 0.72;
}
.stars__rear .stars__star:nth-of-type(21) {
  top: 59vh;
  left: 0vw;
  opacity: 0.26;
}
.stars__rear .stars__star:nth-of-type(22) {
  top: 23vh;
  left: 59vw;
  opacity: 0.13;
}
.stars__rear .stars__star:nth-of-type(23) {
  top: 25vh;
  left: 75vw;
  opacity: 0.69;
}
.stars__rear .stars__star:nth-of-type(24) {
  top: 75vh;
  left: 6vw;
  opacity: 0.42;
}
.stars__rear .stars__star:nth-of-type(25) {
  top: 5vh;
  left: 45vw;
  opacity: 0.39;
}
.stars__rear .stars__star:nth-of-type(26) {
  top: 93vh;
  left: 53vw;
  opacity: 0.57;
}
.stars__rear .stars__star:nth-of-type(27) {
  top: 61vh;
  left: 19vw;
  opacity: 0.64;
}
.stars__rear .stars__star:nth-of-type(28) {
  top: 67vh;
  left: 42vw;
  opacity: 0.44;
}
.stars__rear .stars__star:nth-of-type(29) {
  top: 21vh;
  left: 77vw;
  opacity: 0.31;
}
.stars__rear .stars__star:nth-of-type(30) {
  top: 9vh;
  left: 42vw;
  opacity: 0.6;
}
.stars__rear .stars__star:nth-of-type(31) {
  top: 20vh;
  left: 24vw;
  opacity: 0.55;
}
.stars__rear .stars__star:nth-of-type(32) {
  top: 11vh;
  left: 100vw;
  opacity: 0.46;
}
.stars__rear .stars__star:nth-of-type(33) {
  top: 10vh;
  left: 63vw;
  opacity: 1.05;
}
.stars__rear .stars__star:nth-of-type(34) {
  top: 73vh;
  left: 53vw;
  opacity: 0.42;
}
.stars__rear .stars__star:nth-of-type(35) {
  top: 42vh;
  left: 85vw;
  opacity: 0.94;
}
.stars__rear .stars__star:nth-of-type(36) {
  top: 51vh;
  left: 17vw;
  opacity: 0.31;
}
.stars__rear .stars__star:nth-of-type(37) {
  top: 11vh;
  left: 100vw;
  opacity: 0.29;
}
.stars__rear .stars__star:nth-of-type(38) {
  top: 46vh;
  left: 29vw;
  opacity: 0.74;
}
.stars__rear .stars__star:nth-of-type(39) {
  top: 44vh;
  left: 69vw;
  opacity: 0.53;
}
.stars__rear .stars__star:nth-of-type(40) {
  top: 57vh;
  left: 80vw;
  opacity: 0.69;
}
.stars__rear .stars__star:nth-of-type(41) {
  top: 33vh;
  left: 79vw;
  opacity: 0.11;
}
.stars__rear .stars__star:nth-of-type(42) {
  top: 100vh;
  left: 33vw;
  opacity: 0.62;
}
.stars__rear .stars__star:nth-of-type(43) {
  top: 13vh;
  left: 42vw;
  opacity: 0.36;
}
.stars__rear .stars__star:nth-of-type(44) {
  top: 32vh;
  left: 81vw;
  opacity: 0.8;
}
.stars__rear .stars__star:nth-of-type(45) {
  top: 50vh;
  left: 51vw;
  opacity: 0.36;
}
.stars__rear .stars__star:nth-of-type(46) {
  top: 33vh;
  left: 35vw;
  opacity: 0.79;
}
.stars__rear .stars__star:nth-of-type(47) {
  top: 22vh;
  left: 13vw;
  opacity: 0.94;
}
.stars__rear .stars__star:nth-of-type(48) {
  top: 43vh;
  left: 89vw;
  opacity: 0.83;
}
.stars__rear .stars__star:nth-of-type(49) {
  top: 78vh;
  left: 31vw;
  opacity: 1;
}
.stars__rear .stars__star:nth-of-type(50) {
  top: 87vh;
  left: 93vw;
  opacity: 0.33;
}
.stars__rear .stars__star:nth-of-type(51) {
  top: 84vh;
  left: 7vw;
  opacity: 0.18;
}
.stars__rear .stars__star:nth-of-type(52) {
  top: 86vh;
  left: 26vw;
  opacity: 0.42;
}
.stars__rear .stars__star:nth-of-type(53) {
  top: 26vh;
  left: 26vw;
  opacity: 0.5;
}
.stars__rear .stars__star:nth-of-type(54) {
  top: 64vh;
  left: 0vw;
  opacity: 0.9;
}
.stars__rear .stars__star:nth-of-type(55) {
  top: 45vh;
  left: 61vw;
  opacity: 1;
}
.stars__rear .stars__star:nth-of-type(56) {
  top: 17vh;
  left: 44vw;
  opacity: 0.57;
}
.stars__rear .stars__star:nth-of-type(57) {
  top: 28vh;
  left: 27vw;
  opacity: 0.17;
}
.stars__rear .stars__star:nth-of-type(58) {
  top: 79vh;
  left: 21vw;
  opacity: 0.52;
}
.stars__rear .stars__star:nth-of-type(59) {
  top: 40vh;
  left: 48vw;
  opacity: 0.95;
}
.stars__rear .stars__star:nth-of-type(60) {
  top: 70vh;
  left: 39vw;
  opacity: 0.52;
}
.stars__rear .stars__star:nth-of-type(61) {
  top: 94vh;
  left: 85vw;
  opacity: 0.32;
}
.stars__rear .stars__star:nth-of-type(62) {
  top: 67vh;
  left: 97vw;
  opacity: 0.63;
}
.stars__rear .stars__star:nth-of-type(63) {
  top: 87vh;
  left: 36vw;
  opacity: 0.77;
}
.stars__rear .stars__star:nth-of-type(64) {
  top: 71vh;
  left: 96vw;
  opacity: 0.97;
}
.stars__rear .stars__star:nth-of-type(65) {
  top: 42vh;
  left: 44vw;
  opacity: 0.13;
}
.stars__rear .stars__star:nth-of-type(66) {
  top: 68vh;
  left: 8vw;
  opacity: 0.35;
}
.stars__rear .stars__star:nth-of-type(67) {
  top: 27vh;
  left: 77vw;
  opacity: 0.55;
}
.stars__rear .stars__star:nth-of-type(68) {
  top: 50vh;
  left: 32vw;
  opacity: 0.53;
}
.stars__rear .stars__star:nth-of-type(69) {
  top: 57vh;
  left: 77vw;
  opacity: 0.69;
}
.stars__rear .stars__star:nth-of-type(70) {
  top: 14vh;
  left: 44vw;
  opacity: 0.56;
}
.stars__rear .stars__star:nth-of-type(71) {
  top: 9.........完整代码请登录后点击上方下载按钮下载查看

网友评论0