Learn how to integrate lottie animations into your HTML page effortlessly.
Use the CDN link to include Lottie Script in your HTML page or use the local file path.
<script src="https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.9.6/lottie.min.js"></script>
Create a container for your animation and set its width and height.
<div id="lottie-container" style="width: 300px; height: 300px;"></div>
Load the animation file using the loadAnimation method. Make sure to use proper path for your animation file.
<script>
var animation = lottie.loadAnimation({
container: document.getElementById('lottie-container'),
renderer: 'svg',
loop: true,
autoplay: true,
path: 'animation.json' // Replace with your animation file path
});
</script>
animation.pause(); // Pause
animation.play(); // Play
animation.stop(); // Stop
Find free animations at Unicornicons.