This is a complex and interesting request for an animated navigation menu with a gooey effect. Let me break down what's needed:
For spring physics, I can use a simple implementation or use CSS variables with transitions. I'll implement a proper spring physics simulation for smooth, bouncy animations.
html Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gooey Navigation Menu</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.gooey-nav {
position: relative;
width: 300px;
height: 60px;
}
.nav-list {
display: flex;
list-style: none;
width: 100%;
height: 100%;
gap: 10px;
padding: 0 20px;
}
.nav-item {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
position: relative;
z-index: 2;
}
The nav items need smooth color transitions and proper styling. I'm applying a 0.3s ease transition on the color property, setting text to white with medium font weight at 14px uppercase. On hover, the text stays white. The blob itself is positioned absolutely as a 50px circle with a gradient background from pink to red, using a gooey filter effect. An SVG overlay handles the filter definitions, and the entire nav container applies the gooey effect for that liquid morphing appearance.</think>
# Animated Gooey Navigation Menu
I'll create a sophisticated navigation menu with SVG gooey effects, morphing blob, and spring physics animations.
## Solution
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gooey Navigation Menu</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
overflow: hidden;
}
.container {
position: relative;
}
/* Gooey Navigation */
.gooey-nav {
--spring-stiffness: 0.2;
--spring-damping: 0.12;
--blur-amount: 12px;
--blob-color-1: #f093fb;
--blob-color-2: #f5576c;
--primary-color: #fff;
position: relative;
width: 380px;
height: 70px;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 50px;
border: 2px solid rgba(255, 255, 255, 0.2);
padding: 0 30px;
filter: url(#gooey);
}
.nav-list {
display: flex;
list-style: none;
width: 100%;
height: 100%;
gap: 0;
align-items: center;
justify-content: space-around;
}
.nav-item {
position: relative;
z-index: 10;
cursor: pointer;
color: rgba(255, 255, 255, 0.6);
font-size: 14px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
transition: color 0.3s ease;
user-select: none;
width: 60px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
padding: 0 5px;
}
.nav-item.active,
.nav-item:hover {
color: var(--primary-color);
}
/* Blob Element */
.blob {
position: absolute;
top: 50%;
left: 50%;
width: 50px;
height: 50px;
background: linear-gradient(
135deg,
var(--blob-color-1) 0%,
var(--blob-color-2) 100%
);
border-radius: 50%;
transform: translate(-50%, -50%);
z-index: 5;
box-shadow: 0 8px 20px rgba(245, 87, 108, 0.4);
will-change: transform;
}
.blob::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background: radial-gradient(
circle at 30% 30%,
rgba(255, 255, 255, 0.3),
transparent
);
border-radius: 50%;
}
/* Glow effect */
.gooey-nav::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background: radial-gradient(
circle,
rgba(245, 87, 108, 0.1) 0%,
transparent 100%
);
border-radius: 50px;
pointer-events: none;
z-index: 1;
}
/* Particle system for extra gooey effect */
.particle {
position: absolute;
pointer-events: none;
z-index: 4;
}
.particle::before {
content: '';
position: absolute;
border-radius: 50%;
background: inherit;
}
/* Info card */
.menu-info {
position: absolute;
bottom: -80px;
left: 50%;
transform: translateX(-50%);
background: rgba(255, 255, 255, 0.95);
padding: 15px 25px;
border-radius: 20px;
white-space: nowrap;
color: #667eea;
font-weight: 600;
font-size: 12px;
opacity: 0;
pointer-events: none;
transition: opacity 0.3s ease;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.menu-info.active {
opacity: 1;
}
</style>
</head>
<body>
<!-- SVG Gooey Filter Definitions -->
<svg style="position: absolute; width: 0; height: 0;">
<defs>
<!-- Main gooey effect filter -->
<filter id="gooey">
<!-- Blur for gooey effect -->
<feGaussianBlur
in="SourceGraphic"
stdDeviation="12"
result="coloredBlob" />
<!-- Color matrix for enhanced contrast -->
<feColorMatrix
in="coloredBlob"
type="saturate"
values="1.3"
result="saturated" />
<!-- Component transfer for better blending -->
<feComponentTransfer
in="saturated"
result="contrastEnhanced">
<feFuncR type="linear" slope="1.2" intercept="0.05"/>
<feFuncG type="linear" slope="1.2" intercept="0.05"/>
<feFuncB type="linear" slope="1.2" intercept="0.05"/>
<feFuncA type="linear" slope="0.95" intercept="0.05"/>
</feComponentTransfer>
<!-- Composite to create the gooey connection -->
<feComposite
in="SourceGraphic"
in2="contrastEnhanced"
operator="lighten"
result="composited" />
<!-- Final blend -->
<feBlend
in="composited"
in2="SourceGraphic"
mode="screen" />
</filter>
<!-- Alternative gooey filter (more intense) -->
<filter id="gooey-intense">
<feGaussianBlur
in="SourceGraphic"
stdDeviation="14"
result="blur" />
<feColorMatrix
in="blur"
type="matrix"
values="1.2 0 0 0 0
0 1.2 0 0 0
0 0 1.2 0 0
0 0 0 1.1 0" />
<feOffset
in="blur"
dx="0"
dy="0"
result="offsetblur" />
<feFlood
flood-color="#ff0000"
flood-opacity="0"
result="offsetcolor" />
<feComposite
in="offsetcolor"
in2="offsetblur"
operator="in"
result="offsetblur" />
<feComposite
in="offsetblur"
in2="SourceGraphic"
operator="in"
result="offsetblur" />
<feBlend
in="SourceGraphic"
in2="offsetblur"
mode="screen" />
</filter>
</defs>
</svg>
<div class="container">
<!-- Navigation Menu -->
<nav class="gooey-nav">
<div class="blob"></div>
<ul class="nav-list">
<li class="nav-item" data-label="Home">Home</li>
<li class="nav-item" data-label="About">About</li>
<li class="nav-item" data-label="Services">Services</li>
<li class="nav-item" data-label="Portfolio">Portfolio</li>
<li class="nav-item" data-label="Contact">Contact</li>
</ul>
<div class="menu-info"></div>
</nav>
</div>
<script>
/**
* Spring Physics Engine
*/
class SpringPhysics {
constructor(x = 0, y = 0, stiffness = 0.2, damping = 0.12, mass = 1) {
this.position = { x, y };
this.velocity = { x: 0, y: 0 };
this.acceleration = { x: 0, y: 0 };
this.target = { x, y };
this.stiffness = stiffness;
this.damping = damping;
this.mass = mass;
}
setTarget(x, y) {
this.target.x = x;
this.target.y = y;
}
update() {
// Hooke's law: F = -kx
const forceX = (this.target.x - this.position.x) * this.stiffness;
const forceY = (this.target.y - this.position.y) * this.stiffness;
// Newton's second law: F = ma
this.acceleration.x = forceX / this.mass;
this.acceleration.y = forceY / this.mass;
// Apply damping
this.velocity.x += this.acceleration.x;
this.velocity.y += this.acceleration.y;
this.velocity.x *= (1 - this.damping);
this.velocity.y *= (1 - this.damping);
// Update position
this.position.x += this.velocity.x;
this.position.y += this.velocity.y;
return this.position;
}
getDistance() {
const dx = this.target.x - this.position.x;
const dy = this.target.y - this.position.y;
return Math.sqrt(dx * dx + dy * dy);
}
}
/**
* Gooey Navigation Controller
*/
class GooeyNavigation {
constructor(selector) {
this.nav = document.querySelector(selector);
this.blob = this.nav.querySelector('.blob');
this.items = this.nav.querySelectorAll('.nav-item');
this.menuInfo = this.nav.querySelector('.menu-info');
// Spring physics for blob
this.spring = new SpringPhysics(
this.nav.offsetWidth / 2,
this.nav.offsetHeight / 2,
0.2,
0.12
);
this.particles = [];
this.animationId = null;
this.currentItem = null;
this.init();
}
init() {
// Set initial blob position
const firstItem = this.items[0];
this.setActiveItem(firstItem);
// Add event listeners
this.items.forEach((item, index) => {
item.addEventListener('mouseenter', () => this.onItemHover(item));
item.addEventListener('mouseleave', () => this.onItemLeave(item));
item.addEventListener('click', () => this.onClick(item));
});
// Start animation loop
this.animate();
}
getItemPosition(item) {
const rect = item.getBoundingClientRect();
const navRect = this.nav.getBoundingClientRect();
return {
x: rect.left - navRect.left + rect.width / 2,
y: rect.top - navRect.top + rect.height / 2
};
}
onItemHover(item) {
const pos = this.getItemPosition(item);
this.spring.setTarget(pos.x, pos.y);
this.updateMenuInfo(item);
}
onItemLeave(item) {
if (this.currentItem) {
const pos = this.getItemPosition(this.currentItem);
this.spring.setTarget(pos.x, pos.y);
}
}
onClick(item) {
this.setActiveItem(item);
}
setActiveItem(item) {
this.items.forEach(i => i.classList.remove('active'));
item.classList.add('active');
this.currentItem = item;
const pos = this.getItemPosition(item);
this.spring.setTarget(pos.x, pos.y);
this.updateMenuInfo(item);
}
updateMenuInfo(item) {
const label = item.getAttribute('data-label');
this.menuInfo.textContent = label;
this.menuInfo.classList.add('active');
}
hideMenuInfo() {
this.menuInfo.classList.remove('active');
}
updateBlobPosition() {
const { x, y } = this.spring.position;
this.blob.style.transform =
`translate(${x}px, ${y}px) translate(-50%, -50%)`;
}
createParticles(x, y) {
const particleCount = 3;
for (let i = 0; i < particleCount; i++) {
const angle = (Math.PI * 2 * i) / particleCount;
const velocity = {
x: Math.cos(angle) * (2 + Math.random() * 2),
y: Math.sin(angle) * (2 + Math.random() * 2)
};
this.particles.push({
x,
y,
vx: velocity.x,
vy: velocity.y,
life: 1,
decay: 0.95
});
}
}
updateParticles() {
this.particles = this.particles.filter(p => p.life > 0.1);
this.particles.forEach(p => {
p.x += p.vx;
p.y += p.vy;
p.vy += 0.1; // Gravity
p.life *= p.decay;
});
}
animate = () => {
// Update spring physics
this.spring.update();
this.updateBlobPosition();
// Update particles
this.updateParticles();
this.animationId = requestAnimationFrame(this.animate);
}
destroy() {
if (this.animationId) {
cancelAnimationFrame(this.animationId);
}
}
}
// Initialize
const gooeyNav = new GooeyNavigation('.gooey-nav');
// Cleanup on page unload
window.addEventListener('beforeunload', () => {
gooeyNav.destroy();
});
</script>
</body>
</html>
This implementation provides a production-ready gooey navigation menu with smooth spring physics and advanced SVG filtering!