CSS Live Preview Available

Bubble Animation

Floating bubble animation for background decoration

CSS3AnimationBubbleKeyframesBackground

Code

.bubble-container {
  width: 400px;
  height: 300px;
  background: #667eea;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}
.bubble {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  animation: float 8s infinite ease-in-out;
}
.bubble:nth-child(1) {
  width: 60px;
  height: 60px;
  bottom: -60px;
  left: 10%;
  animation-delay: 0s;
}
.bubble:nth-child(2) {
  width: 80px;
  height: 80px;
  bottom: -80px;
  left: 30%;
  animation-delay: 1s;
}
.bubble:nth-child(3) {
  width: 40px;
  height: 40px;
  bottom: -40px;
  left: 50%;
  animation-delay: 2s;
}
.bubble:nth-child(4) {
  width: 70px;
  height: 70px;
  bottom: -70px;
  left: 70%;
  animation-delay: 1.5s;
}
.bubble:nth-child(5) {
  width: 50px;
  height: 50px;
  bottom: -50px;
  left: 90%;
  animation-delay: 0.5s;
}
@keyframes float {
  0% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-250px) scale(1.2);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

HTML

<"attr-name"</span>>class</span>="tag"</span>>div</span> "attr-name"</span>>class</span>="bubble-container"</span>>
  <"attr-name"</span>>class</span>="tag"</span>>div</span> "attr-name"</span>>class</span>="bubble"</span>></"attr-name"</span>>class</span>="tag"</span>>div</span>>
  <"attr-name"</span>>class</span>="tag"</span>>div</span> "attr-name"</span>>class</span>="bubble"</span>></"attr-name"</span>>class</span>="tag"</span>>div</span>>
  <"attr-name"</span>>class</span>="tag"</span>>div</span> "attr-name"</span>>class</span>="bubble"</span>></"attr-name"</span>>class</span>="tag"</span>>div</span>>
  <"attr-name"</span>>class</span>="tag"</span>>div</span> "attr-name"</span>>class</span>="bubble"</span>></"attr-name"</span>>class</span>="tag"</span>>div</span>>
  <"attr-name"</span>>class</span>="tag"</span>>div</span> "attr-name"</span>>class</span>="bubble"</span>></"attr-name"</span>>class</span>="tag"</span>>div</span>>
</"attr-name"</span>>class</span>="tag"</span>>div</span>>

Live Preview