티스토리 뷰

Youtube 따라하기

파티클 이펙트2

트라이에이스 2021. 2. 1. 17:20

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Animated Christmas Banner using Html CSS & Javascript | CSS Animation Effects</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style type="text/css">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body { 
  overflow: hidden;
}
section {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #f1f1f1;
}
section .box {
  position: absolute;
  width: 450px;
  height: 450px;
}
section .box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, #000, transparent);
  opacity: 0.1;
  transform: rotate(45deg);
  transform-origin: left;

}
section .box .circle {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #fff, #e4e3e8);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  z-index: 1;
}
section .box .circle::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  bottom: 5px;
  background: linear-gradient(315deg, #fff, #e4e3e8);
  border-radius: 50%;
}
section .box .circle h2 {
  position: absolute;
  z-index: 2;
  font-size: 4em;
  color: #ff2a2a;
  text-align: center;
}
section i {
  position: absolute;
  background: #ff2a2a;
  border-radius: 100%;
  animation: animate 5s linear infinite;
}
section i:nth-child(even) {
  background: transparent;
  border: 1px solid #ff2a2a;
}
@keyframes animate {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-2000%);
    opacity: 0;
  }
}
</style>

</head>

<body>
<section>
  <div class="box">
    <div class="circle">
      <h2>Happy<br>Christmas</h2>
    </div>
  </div>
</section>

<script>
function bubbles() {
  var count = 200;
  var section = document.querySelector('section');
  var i = 0;
  while (i < count) {
    var bubble = document.createElement('i');
    var x = Math.floor(Math.random() * window.innerWidth);
    var y = Math.floor(Math.random() * window.innerHeight);

    var size = Math.random() * 10;
    bubble.style.left = x+'px';
    bubble.style.top = y+'px';
    bubble.style.width = 1+size+'px';
    bubble.style.height = 1+size+'px';

    bubble.style.animationDuration = 5+size+'s';
    bubble.style.animationDelay = -size+'s';
    
    section.appendChild(bubble);
    i++;
  }
}
bubbles();
</script>
</body>
</html>

출처: www.youtube.com/watch?v=j7MWgFeL1pw&list=LL&index=7&t=69s&ab_channel=OnlineTutorials

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함