Creating a fake Windows 95 system using HTML, CSS, and JavaScript is a fun project that involves simulating the look and feel of the classic operating system. Below, I will guide you through the process step by step, breaking it into manageable components.
1. Understand the Components of Windows 95
Windows 95 had several key visual elements:
- Start Menu: A button in the bottom-left corner.
- Taskbar: A bar at the bottom of the screen showing open applications.
- Desktop Icons: Shortcuts to programs or files.
- Windows: Rectangular windows with title bars, minimize/maximize/close buttons, and content areas.
- System Tray: Icons for system utilities like clock, volume, etc.
We will recreate these elements using HTML, CSS, and JavaScript.
2. Project Structure
Organize your project as follows:
/windows95
├── index.html
├── style.css
└── script.js
3. HTML: Define the Layout
The HTML file will define the structure of the desktop, taskbar, and windows.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fake Windows 95</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- Desktop -->
<div class="desktop">
<!-- Desktop Icons -->
<div class="icon">My Computer</div>
<div class="icon">Recycle Bin</div>
<div class="icon">Internet Explorer</div>
</div>
<!-- Taskbar -->
<div class="taskbar">
<button class="start-button">Start</button>
<div class="taskbar-items"></div>
<div class="system-tray">
<span class="clock">12:00 PM</span>
</div>
</div>
<!-- Windows -->
<div class="window hidden" id="explorer-window">
<div class="title-bar">
<span class="title">My Computer</span>
<div class="controls">
<button class="minimize">-</button>
<button class="maximize">□</button>
<button class="close">X</button>
</div>
</div>
<div class="content">
<p>Welcome to My Computer!</p>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
4. CSS: Style the Elements
The CSS file will make the interface look like Windows 95.
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
background-color: #c0c0c0; /* Windows 95 gray */
color: black;
display: flex;
flex-direction: column;
height: 100vh;
}
/* Desktop */
.desktop {
flex: 1;
display: grid;
grid-template-columns: repeat(auto-fill, 100px);
gap: 20px;
padding: 20px;
align-content: start;
}
.icon {
width: 80px;
height: 80px;
background-color: white;
border: 1px solid #888;
text-align: center;
line-height: 80px;
font-size: 12px;
cursor: pointer;
}
/* Taskbar */
.taskbar {
height: 30px;
background-color: #000080; /* Windows 95 blue */
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 10px;
color: white;
}
.start-button {
background-color: #000080;
color: white;
border: none;
padding: 5px 10px;
cursor: pointer;
}
.system-tray {
display: flex;
align-items: center;
}
.clock {
margin-left: 10px;
}
/* Windows */
.window {
position: absolute;
width: 400px;
height: 300px;
background-color: white;
border: 2px solid #888;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
display: flex;
flex-direction: column;
}
.title-bar {
background-color: #000080;
color: white;
padding: 5px;
display: flex;
justify-content: space-between;
align-items: center;
}
.controls button {
background-color: #000080;
color: white;
border: none;
padding: 2px 5px;
cursor: pointer;
}
.content {
flex: 1;
padding: 10px;
overflow-y: auto;
}
.hidden {
display: none;
}
5. JavaScript: Add Interactivity
The JavaScript file will handle interactions like opening windows, minimizing, maximizing, and closing them.
// Select elements
const startButton = document.querySelector('.start-button');
const explorerWindow = document.getElementById('explorer-window');
const minimizeButton = explorerWindow.querySelector('.minimize');
const maximizeButton = explorerWindow.querySelector('.maximize');
const closeButton = explorerWindow.querySelector('.close');
// Open window
startButton.addEventListener('click', () => {
explorerWindow.classList.remove('hidden');
});
// Minimize window
minimizeButton.addEventListener('click', () => {
explorerWindow.classList.add('hidden');
});
// Maximize/Restore window
let isMaximized = false;
maximizeButton.addEventListener('click', () => {
if (isMaximized) {
explorerWindow.style.width = '400px';
explorerWindow.style.height = '300px';
} else {
explorerWindow.style.width = '800px';
explorerWindow.style.height = '600px';
}
isMaximized = !isMaximized;
});
// Close window
closeButton.addEventListener('click', () => {
explorerWindow.classList.add('hidden');
});
6. Final Touches
- Add more windows and icons as needed.
- Implement drag-and-drop functionality for windows using JavaScript.
- Add animations for opening/closing windows.
- Use a library like
moment.js to dynamically update the clock.
7. Testing and Deployment
- Test the project locally in your browser.
- Deploy it to platforms like GitHub Pages, Netlify, or Vercel to share it online.
This approach provides a basic but functional recreation of a Windows 95 system. You can expand it further by adding more features, such as a working Start Menu, context menus, and more interactive elements.