<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML5 Ad Banner</title>
<style>
body,
html {
margin: 0;
padding: 0;
width: 300px;
/* Adjust as per your ad size */
height: 250px;
/* Adjust as per your ad size */
overflow: hidden;
}
.banner {
width: 100%;
height: 100%;
position: relative;
background-color: #0099cc;
/* Background color */
color: #ffffff;
/* Text color */
display: flex;
justify-content: center;
align-items: center;
text-align: center;
font-family: Arial, sans-serif;
}
.banner a {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 2;
background-color: rgba(0, 0, 0, 0);
/* Invisible color */
display: block;
text-decoration: none;
}
.content {
z-index: 1;
}
@keyframes panInFromLeft {
from {
opacity: 0;
transform: translateX(-100%);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes panInFromTop {
from {
opacity: 0;
transform: translateY(-100%);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes panInFromRight {
from {
opacity: 0;
transform: translateX(100%);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes panInFromBottom {
from {
opacity: 0;
transform: translateY(100%);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Wrapper to hide overflow */
.letter-wrapper {
display: inline-block;
overflow: hidden;
/* Adjust based on actual font size and letter spacing */
height: 1.2em;
/* Adjust based on actual font size */
}
.letter {
display: inline-block;
opacity: 0;
/* Start fully transparent */
/* Ensure letters are positioned back in their original place after animation */
transform: translateX(0) translateY(0);
}
.animate-heading {
font-size: 1.8rem;
letter-spacing: 0.2rem;
}
</style>
</head>
<body>
<div class="banner">
<a href="http://www.yourlink.com" target="_blank" rel="noopener noreferrer"></a>
<div class="content">
<div class="animate-heading" id="animatedWord">
</div>
<p>Some description or call to action.</p>
</div>
</div>
</body>
<script>
document.addEventListener('DOMContentLoaded', () => {
const word = 'Animate';
let directions = ['panInFromLeft', 'panInFromTop', 'panInFromRight', 'panInFromBottom'];
let currentAnimation = 0;
const container = document.getElementById('animatedWord');
container.innerHTML = [...word].map(letter => `<span class="letter-wrapper"><span class="letter">${letter}</span></span>`).join('');
const animateLetters = () => {
document.querySelectorAll('#animatedWord .letter').forEach((span, index) => {
// Calculate delay based on letter index
let delay = index * 100;
// Remove any existing animation to re-trigger it
span.style.animation = 'none';
// Force reflow to reset animation
void span.offsetWidth;
// Apply new animation with delay
let direction = directions[(currentAnimation + index) % directions.length];
span.style.animation = `${direction} 1s ${delay}ms forwards`;
});
// Schedule next animation cycle
currentAnimation++;
setTimeout(animateLetters, word.length * 100 + 3000); // Adjust timing as needed
};
animateLetters();
});
</script>
</html>
1
1
2KB
5KB
197.0ms
212.0ms
244.0ms