Calculator Tools Calculator Tools
Create

M and N Marching

Nov 13, 2023

About this app

A fun web app where the letters M and N march across the screen.

M and N Marching

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>M and N Marching</title>
<meta name="description" content="A fun web app where the letters M and N march across the screen.">
<meta name="keywords" content="M, N, marching, letters, animation">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.
document.addEventListener("DOMContentLoaded", function() {
var container = document.getElementById('main-container');
var marchingLetters = ['M', 'N'];
var colors = ['#F44336', '#2196F3']; // Red and Blue
var currentPosition = 0;

function march() {
var letter = marchingLetters[currentPosition];
var color = colors[currentPosition];

var marchingLetter = document.createElement('div');
marchingLetter.textContent = letter;
marchingLetter.style.color = color;
marchingLetter.className = 'marching-letter';

container.appendChild(marchingLetter);

var position = -100;
var animationDuration = 3000; // 3 seconds

function animate() {
position += 1;
marchingLetter.style.transform = 'translateX(' + position + 'px)';

if (position < container.offsetWidth) {
requestAnimationFrame(animate);
} else {
container.removeChild(marchingLetter);
}
}

animate();
}

setInterval(function() {
march();
currentPosition = (currentPosition + 1) % marchingLetters.length;
}, 1000);
});
} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>

<style>
/* App CSS Goes Here */
.marching-letter {
position: absolute;
top: 50%;
font-size: 36px;
font-weight: bold;
transform: translateX(-100px);
animation: fade-in 0.5s ease-in-out;
}

@keyframes fade-in {
0% {
opacity: 0;
}

100% {
opacity: 1;
}
}
</style>
</head>
<body>
<div id="main-container" class="container">
<!-- App HTML Goes Here -->
</div>
</body>
</html>