Discussion:
Animations, movement, coding
What are you trying to achieve:
I have a client that would like a simple animation come and go upon opening the homepage. For example: Balloon overlay that floats up and off the page or snowflakes that fall from the top of the page and disappear. How can I achieve this in Wix. The same client is also looking for a few other animations on their page like words being ‘drawn out’ by a moving pen and when you click on a button it displays an animation before loading the new page.
Thanks!
simple baloon-animation…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
.balloon {
width: 50px;
height: 70px;
border-radius: 50%;
position: absolute;
animation: floatUp 5s linear infinite;
}
@keyframes floatUp {
0% {
bottom: -100px;
opacity: 0;
}
50% {
opacity: 1;
}
100% {
bottom: 100vh;
opacity: 0;
}
}
</style>
<script defer>
document.addEventListener("DOMContentLoaded", function() {
// Generate 10 balloons with random colors and delays
for (let i = 0; i < 10; i++) {
createBalloon();
}
function createBalloon() {
const balloon = document.createElement("div");
balloon.className = "balloon";
// Set random position
balloon.style.left = Math.random() * window.innerWidth + "px";
// Set random color
balloon.style.backgroundColor = getRandomColor();
// Set random animation delay
balloon.style.animationDelay = Math.random() * 5 + "s";
// Append balloon to the body
document.body.appendChild(balloon);
}
function getRandomColor() {
const letters = "0123456789ABCDEF";
let color = "#";
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
});
</script>
</head>
<body>
</body>
</html>