Here's an animated SVG of a running unicorn with enhanced details, dynamic motion, and magical sparkle effects. This version includes four moving legs, a flowing mane and tail, and sparkles for a whimsical touch. The animation is smooth and self-contained.
✨ Final Result (Copy-Paste Ready)
<svg width="400" height="200" viewBox="0 0 400 200" xmlns="http://www.w3.org/2000/svg">
<style>
/* Body bounce */
@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
/* Leg animations */
@keyframes front-leg {
0% { transform: rotate(0deg); }
25% { transform: rotate(30deg); }
50% { transform: rotate(0deg); }
75% { transform: rotate(-20deg); }
}
@keyframes back-leg {
0% { transform: rotate(0deg); }
25% { transform: rotate(-20deg); }
50% { transform: rotate(0deg); }
75% { transform: rotate(30deg); }
}
/* Tail and mane */
@keyframes tail {
0%, 100% { transform: rotate(0deg); }
50% { transform: rotate(15deg); }
}
@keyframes mane {
0%, 100% { transform: rotate(0deg); }
50% { transform: rotate(-5deg); }
}
/* Sparkle animation */
@keyframes sparkle {
0% { opacity: 0; transform: scale(0.5); }
50% { opacity: 1; transform: scale(1); }
100% { opacity: 0; transform: scale(0.5); }
}
.unicorn {
animation: bounce 0.6s ease-in-out infinite;
}
.front-leg {
animation: front-leg 0.6s ease-in-out infinite;
}
.back-leg {
animation: back-leg 0.6s ease-in-out infinite;
}
.tail {
animation: tail 0.6s ease-in-out infinite;
}
.mane {
animation: mane 0.6s ease-in-out infinite;
}
.sparkle {
animation: sparkle 1.2s infinite;
}
</style>
<!-- Sparkles -->
<g class="sparkle">
<circle cx="50" cy="50" r="2" fill="#FFD700" opacity="0"/>
<circle cx="70" cy="40" r="2" fill="#FFD700" opacity="0"/>
<circle cx="90" cy="55" r="2" fill="#FFD700" opacity="0"/>
</g>
<!-- Unicorn group -->
<g class="unicorn">
<!-- Body -->
<ellipse cx="200" cy="110" rx="40" ry="25" fill="#FFF" stroke="#333" stroke-width="2"/>
<!-- Head -->
<path d="M240,90 Q255,80 265,95 Q270,105 260,115 Q250,125 240,115" fill="#FFF" stroke="#333" stroke-width="2"/>
<!-- Eye -->
<circle cx="260" cy="100" r="3" fill="#000"/>
<!-- Horn -->
<polygon points="265,95 270,80 275,95" fill="#FFD700" stroke="#FFA500" stroke-width="1"/>
<!-- Mane -->
<g class="mane">
<path d="M245,90 Q240,80 230,90" fill="#FF69B4" stroke="#FF1493" stroke-width="1"/>
<path d="M250,90 Q245,80 240,90" fill="#FF69B4" stroke="#FF1493" stroke-width="1"/>
<path d="M255,90 Q250,80 245,90" fill="#FF69B4" stroke="#FF1493" stroke-width="1"/>
</g>
<!-- Tail -->
<g class="tail">
<path d="M160,110 Q150,100 140,110" fill="#FF69B4" stroke="#FF1493" stroke-width="1"/>
<path d="M160,110 Q150,120 140,110" fill="#FF69B4" stroke="#FF1493" stroke-width="1"/>
</g>
<!-- Legs -->
<line class="front-leg" x1="180" y1="135" x2="180" y2="150" stroke="#333" stroke-width="4"/>
<line class="back-leg" x1="200" y1="135" x2="200" y2="150" stroke="#333" stroke-width="4"/>
<line class="front-leg" x1="220" y1="135" x2="220" y2="150" stroke="#333" stroke-width="4"/>
<line class="back-leg" x1="240" y1="135" x2="240" y2="150" stroke="#333" stroke-width="4"/>
</g>
<!-- Ground -->
<line x1="0" y1="155" x2="400" y2="155" stroke="#8B4513" stroke-width="4"/>
</svg>
🌟 Key Features
- Four animated legs with staggered motion for a galloping effect.
- Bouncing body to simulate running momentum.
- Flowing mane and tail using rotation animations.
- Sparkles for a magical touch (opacity and scale animation).
- Responsive design with a
viewBox for scaling.
🛠️ Customization Tips
- Speed: Adjust the animation duration in
.unicorn and leg classes.
- Colors: Change
fill values for the unicorn's body, mane, or tail.
- Sparkles: Add more circles or animate them along a path for advanced effects.
- Background: Add clouds, stars, or a sun with additional SVG shapes.
📌 How to Use
- Copy the SVG code into an
.html file.
- Open it in a browser to see the unicorn run!
- Embed it directly into your website or app.
Let me know if you want a version with a background landscape, clouds, or nighttime stars! 🌈