Recursive Windows 98 UI Simulation
Here's a complete implementation of a recursive Windows 98-style interface with animations between recursive layers. The solution includes HTML, CSS, and JavaScript to create a visually accurate Windows 98 aesthetic with controlled recursion depth and smooth transitions.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Windows 98 Recursive UI</title>
<style>
/* Windows 98 Color Palette */
:root {
--win98-titlebar-active: #000080;
--win98-titlebar-inactive: #c0c0c0;
--win98-titlebar-text: #ffffff;
--win98-menu-bg: #c0c0c0;
--win98-menu-text: #000000;
--win98-border-dark: #808080;
--win98-border-light: #ffffff;
--win98-content-bg: #c0c0c0;
--win98-highlight: #000080;
--win98-highlight-text: #ffffff;
--win98-shadow: #808080;
}
body {
margin: 0;
padding: 0;
background-color: #008080;
font-family: 'MS Sans Serif', Arial, sans-serif;
font-size: 12px;
overflow: hidden;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.window-container {
position: relative;
width: 600px;
height: 400px;
box-shadow: 3px 3px 0px var(--win98-shadow);
background-color: var(--win98-content-bg);
border: 2px solid;
border-color: var(--win98-border-dark) var(--win98-border-light) var(--win98-border-light) var(--win98-border-dark);
overflow: hidden;
}
.title-bar {
background: linear-gradient(to right, var(--win98-titlebar-active), #101080);
color: var(--win98-titlebar-text);
padding: 2px 4px;
display: flex;
justify-content: space-between;
align-items: center;
height: 20px;
font-weight: bold;
position: relative;
}
.title-bar-text {
pointer-events: none;
}
.window-controls {
display: flex;
gap: 2px;
}
.window-control {
width: 16px;
height: 14px;
border: 1px solid;
border-color: var(--win98-border-light) var(--win98-border-dark) var(--win98-border-dark) var(--win98-border-light);
display: flex;
justify-content: center;
align-items: center;
font-size: 10px;
background-color: var(--win98-titlebar-active);
color: var(--win98-titlebar-text);
cursor: pointer;
}
.window-control:hover {
background-color: var(--win98-highlight);
}
.menu-bar {
background-color: var(--win98-menu-bg);
height: 20px;
display: flex;
border-bottom: 1px solid var(--win98-border-dark);
}
.menu-item {
padding: 0 10px;
display: flex;
align-items: center;
height: 100%;
cursor: pointer;
}
.menu-item:hover {
background-color: var(--win98-highlight);
color: var(--win98-highlight-text);
}
.content-area {
height: calc(100% - 40px);
padding: 4px;
overflow: auto;
background-color: var(--win98-content-bg);
position: relative;
}
.status-bar {
background-color: var(--win98-menu-bg);
height: 20px;
display: flex;
align-items: center;
padding: 0 4px;
border-top: 1px solid var(--win98-border-dark);
font-size: 11px;
}
.window-frame {
width: 100%;
height: 100%;
border: 2px solid;
border-color: var(--win98-border-dark) var(--win98-border-light) var(--win98-border-light) var(--win98-border-dark);
position: relative;
overflow: hidden;
}
.iframe-container {
width: 100%;
height: 100%;
transition: transform 0.5s ease, opacity 0.5s ease;
}
.iframe-container.hidden {
transform: scale(0.9);
opacity: 0;
}
iframe {
width: 100%;
height: 100%;
border: none;
background-color: var(--win98-content-bg);
}
.depth-indicator {
position: absolute;
bottom: 4px;
right: 4px;
background-color: var(--win98-menu-bg);
padding: 2px 4px;
border: 1px solid var(--win98-border-dark);
font-size: 10px;
}
.loading-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(192, 192, 192, 0.7);
display: flex;
justify-content: center;
align-items: center;
z-index: 10;
transition: opacity 0.3s ease;
}
.loading-overlay.hidden {
opacity: 0;
pointer-events: none;
}
.loading-text {
font-size: 14px;
font-weight: bold;
color: var(--win98-menu-text);
}
</style>
</head>
<body>
<div class="window-container" id="root-window">
<div class="title-bar">
<span class="title-bar-text">Windows 98 Recursive Explorer</span>
<div class="window-controls">
<div class="window-control">_</div>
<div class="window-control">□</div>
<div class="window-control">X</div>
</div>
</div>
<div class="menu-bar">
<div class="menu-item">File</div>
<div class="menu-item">Edit</div>
<div class="menu-item">View</div>
<div class="menu-item">Favorites</div>
<div class="menu-item">Tools</div>
<div class="menu-item">Help</div>
</div>
<div class="content-area">
<div class="window-frame">
<div class="iframe-container" id="iframe-container">
<div class="loading-overlay" id="loading-overlay">
<div class="loading-text">Loading...</div>
</div>
<iframe id="recursive-iframe" src="about:blank"></iframe>
</div>
<div class="depth-indicator" id="depth-indicator">Depth: 0</div>
</div>
</div>
<div class="status-bar">
<span>Ready</span>
</div>
</div>
<script>
// Configuration
const MAX_DEPTH = 5;
const ANIMATION_DURATION = 500; // ms
// Get current depth from URL or set to 0
const urlParams = new URLSearchParams(window.location.search);
let currentDepth = parseInt(urlParams.get('depth')) || 0;
// Update depth indicator
document.getElementById('depth-indicator').textContent = `Depth: ${currentDepth}`;
// Check if we should create a recursive iframe
if (currentDepth < MAX_DEPTH) {
const iframe = document.getElementById('recursive-iframe');
const iframeContainer = document.getElementById('iframe-container');
const loadingOverlay = document.getElementById('loading-overlay');
// Set the iframe source to the same page with increased depth
iframe.src = `?depth=${currentDepth + 1}`;
// Show loading overlay
loadingOverlay.classList.remove('hidden');
// When iframe loads, animate it in
iframe.onload = function() {
setTimeout(() => {
loadingOverlay.classList.add('hidden');
iframeContainer.classList.remove('hidden');
}, 300);
};
// Add click handler to the content area to trigger animation
document.querySelector('.content-area').addEventListener('click', function() {
if (currentDepth < MAX_DEPTH - 1) {
// Animate out
iframeContainer.classList.add('hidden');
// After animation completes, reload the iframe to show the next depth
setTimeout(() => {
iframe.src = `?depth=${currentDepth + 1}`;
loadingOverlay.classList.remove('hidden');
}, ANIMATION_DURATION);
}
});
} else {
// At max depth, show a message
const iframeContainer = document.getElementById('iframe-container');
iframeContainer.innerHTML = `
<div style="display: flex; justify-content: center; align-items: center; height: 100%;">
<div style="text-align: center; padding: 20px;">
<div style="font-size: 16px; margin-bottom: 10px;">Maximum recursion depth reached</div>
<div style="font-size: 12px; color: #808080;">(Depth: ${currentDepth})</div>
</div>
</div>
`;
}
// Add some Windows 98-like behavior
document.querySelector('.window-control').addEventListener('click', function() {
alert("This is a simulation of Windows 98.\n\nClick the content area to advance to the next recursion level.");
});
</script>
</body>
</html>
Key Features:
-
Authentic Windows 98 Aesthetic:
- Classic title bar with gradient
- Menu bar with proper styling
- Window controls (minimize, maximize, close)
- Proper border styling with light/dark edges
- Status bar at the bottom
-
Recursive Implementation:
- Each window embeds another identical window via iframe
- Depth is controlled via URL parameter
- Maximum depth is configurable (set to 5 in this example)
-
Animation System:
- Smooth transitions between recursive layers
- Loading overlay with fade effect
- Scale and opacity animations when navigating deeper
-
Dynamic Depth Handling:
- Depth indicator shows current recursion level
- At maximum depth, shows a termination message
- Clicking the content area advances to the next level
-
Responsive Design:
- Properly sized window container
- Scrollable content area
- Maintains aspect ratios during animations
To use this, simply save the code as an HTML file and open it in a browser. Each click on the content area will advance to the next recursion level with a smooth animation. The maximum depth is set to 5 levels, but you can adjust this by changing the MAX_DEPTH constant in the JavaScript.
The implementation avoids infinite recursion by using the URL parameter to track depth, which is a more reliable approach than trying to manage it purely in memory.