About this snippet

Add a playful touch to your website with these floating background bubbles. They move slowly across the screen using pure CSS animations, creating a dynamic atmosphere without distracting from your content.

Size
1.5 KB
Uses
HTML, CSS
Loads
Nothing external
Views
568
<div class="bubble-bg">
  <div class="bubble"></div>
  <div class="bubble"></div>
  <div class="bubble"></div>
  <div class="bubble"></div>
  <div class="center-content">
    <h1>Floating Bubbles</h1>
  </div>
</div>
.bubble-bg {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  width: 100%;
  height: 400px;
  background: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}
.center-content {
  z-index: 2;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.1);
  font-size: 2rem;
}
.bubble {
  position: absolute;
  bottom: -100px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  animation: rise 10s infinite linear;
}
.bubble:nth-child(1) {
  width: 80px;
  height: 80px;
  left: 10%;
  animation-duration: 8s;
}
.bubble:nth-child(2) {
  width: 40px;
  height: 40px;
  left: 20%;
  animation-duration: 12s;
  animation-delay: 2s;
}
.bubble:nth-child(3) {
  width: 120px;
  height: 120px;
  left: 70%;
  animation-duration: 15s;
  animation-delay: 1s;
}
.bubble:nth-child(4) {
  width: 60px;
  height: 60px;
  left: 85%;
  animation-duration: 9s;
  animation-delay: 4s;
}
@keyframes rise {
  0% {
    bottom: -100px;
    transform: translateX(0);
  }
  50% {
    transform: translateX(50px);
  }
  100% {
    bottom: 108%;
    transform: translateX(-50px);
  }
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save