particles+svg实现宇宙星星天体转动流星雨动画效果代码

代码语言:html

所属分类:动画

代码描述:particles+svg实现宇宙星星天体转动流星雨动画效果代码,点击鼠标任意位置可产生更多星星。

代码标签: particles svg 宇宙 星星 天体 转动 流星雨 动画

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

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

<head>
    <meta charset="UTF-8">
<style>
    h3 {
  width: 100%;
  color: #fff;
  font-family: sans-serif;
  font-weight: 200;
}

body {
  background-color: #0f022e;
  text-align: center;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#galaxy {
  position: relative;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  overflow: hidden;
  z-index: 1;
  border: solid rgba(42, 218, 218, 0.1) 4px;
}

.planet {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(to right, #de0061 0%, #00a2a5 100%);
  left: 60%;
  top: 53%;
  transform: rotate(10deg);
  transform-origin: center;
  box-shadow: 0px 0px 4px 10px rgba(139, 49, 169, 0.52), 0px 0px 4px 20px rgba(63, 167, 143, 0.22);
  z-index: 1;
  animation: float infinite 10s ease-in-out alternate;
}

@keyframes float {
  from {
    transform: translate(-20px, 20px) rotate(10deg);
  }
  to {
    transform: translate(20px, -20px) rotate(-30deg);
  }
}
.planet:before {
  content: "";
  position: absolute;
  width: 400px;
  height: 400px;
  left: -160px;
  top: -160px;
  border-radius: 50%;
  background-color: rgba(42, 218, 218, 0.1);
  filter: blur(40px);
  z-index: -999;
  pointer-events: none;
}

#ring {
  position: absolute;
  width: 195px;
  height: 135px;
  left: -46%;
  top: -13%;
  transform: rotate(-20deg);
}

.ring-style {
  opacity: 0.38;
  fill: none;
  stroke: url(#SVGID_1_);
  stroke-width: 6.4984;
  stroke-linecap: round;
  stroke-miterlimit: 10;
}

.comet {
  position: absolute;
  width: 4px;
  height: 100px;
  opacity: 0.8;
  background: linear-gradient(to bottom, rgba(87, 64, 212, 0.4) 0%, #de0061 50%, #EEF139 100%);
  left: 20%;
  border-radius: 10px;
  top: 53%;
  transform: rotate(40deg);
  box-shadow: 0px 0px 75px 2px white;
}

.c-container {
  position: absolute;
  top: -43%;
  left: 71%;
  width: 200px;
  height: 200px;
  animation: comets 1 8s ease-in-out 5s;
}

@keyframes comets {
  from {
    transform: translate(300%, -300%);
  }
  to {
    transform: translate(-300%, 300%);
  }
}
.comet:after {
  position: absolute;
  content: "";
  width: 4px;
  height: 80px;
  opacity: 0.8;
  background: linear-gradient(to bottom, rgba(87, 64, 212, 0.4) 0%, #de0061 50%, #EEF139 100%);
  left: -400%;
  border-radius: 10px;
  top: 53%;
  box-shadow: 0px 0px 75px 2px white;
}

.comet:before {
  position: absolute;
  content: "";
  width: 4px;
  height: 80px;
  opacity: 0.8;
  background: linear-gradient(to bottom, rgba(87, 64, 212, 0.4) 0%, #de0061 50%, #EEF139 100%);
  left: 400%;
  border-radius: 10px;
  top: 33%;
  box-shadow: 0px 0px 75px 2px white;
}
</style>
</head>

<body>
    <!-- partial:index.partial.html -->
    <div id="galaxy">

        <div class="planet">
            <svg id="ring" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 152.5 135.6">
  <radialGradient id="SVGID_1_" cx="40.124" cy="364.76" r="65.295" gradientTransform="matrix(.3997 .9167 -.1528 .0666 518.507 -167.787)" gradientUnits="user.........完整代码请登录后点击上方下载按钮下载查看

网友评论0