# Floating Shadow

> An object that bobs up and down while its ground shadow shrinks and fades in sync.

- Category: [CSS Box Shadows](https://copy-css.com/category/shadows)
- Tags: float, levitate, bob, ground shadow, animation
- Live preview: https://copy-css.com/snippets/floating-shadow
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<div class="float">
  <div class="float-item"></div>
</div>
```

## CSS

```css
.float {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}

.float-item {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  background: linear-gradient(135deg, #34d399, #0ea5e9);
  animation: float-y 3s ease-in-out infinite;
}

/* The ground shadow stays put and breathes */
.float::after {
  content: "";
  width: 70px;
  height: 12px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.35);
  filter: blur(3px);
  animation: float-shadow 3s ease-in-out infinite;
}

@keyframes float-y {
  50% { transform: translateY(-14px); }
}

@keyframes float-shadow {
  50% { transform: scale(0.7); opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
  .float-item,
  .float::after { animation: none; }
}
```

## Notes

- This CSS Floating Shadow is 38 lines of pure CSS (0.7 KB) with no JavaScript and no dependencies. It uses keyframe animations, transforms, linear gradients and filters.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
