Creating a single-page HTML screensaver without using any text can be achieved using HTML, CSS, and JavaScript to create a visually engaging visual effect. Below is an example of a screensaver that features animated moving circles of different sizes and colors.
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Screensaver</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: black;
}
.circle {
position: absolute;
border-radius: 50%;
animation: move 10s infinite;
opacity: 0.7;
}
@keyframes move {
0% {
transform: translate(0, 0);
}
25% {
transform: translate(calc(100vw - 100px), 0);
}
50% {
transform: translate(calc(100vw - 100px), calc(100vh - 100px));
}
75% {
transform: translate(0, calc(100vh - 100px));
}
100% {
transform: translate(0, 0);
}
}
</style>
</head>
<body>
<script>
function createCircle() {
const circle = document.createElement('div');
const size = Math.random() * 100 + 30; // Randomize size between 30px and 130px
const leftPosition = Math.random() * window.innerWidth;
const topPosition = Math.random() * window.innerHeight;
const color = `hsl(${Math.random() * 360}, 100%, 50%)`; // Random color
circle.className = 'circle';
circle.style.width = `${size}px`;
circle.style.height = `${size}px`;
circle.style.backgroundColor = color;
circle.style.left = `${leftPosition}px`;
circle.style.top = `${topPosition}px`;
circle.style.animationDuration = `${Math.random() * 5 + 5}s`; // Animation duration between 5s and 10s
document.body.appendChild(circle);
// Remove circle after its animation duration
setTimeout(() => {
circle.remove();
}, 10000); // Remove after 10s to match animation duration
}
// Create circles at intervals
setInterval(createCircle, 1000); // Create a new circle every second
</script>
</body>
</html>
Explanation
HTML: The structure is very simple; it mainly consists of a body element where the circles will be dynamically added via JavaScript.
CSS:
The body is styled to have no margin, a hidden overflow, and a black background.
The .circle class defines the properties of the circles, including their shape and animation.
The @keyframes move rule creates a basic animation that makes the circles move along a quadrilateral path (back and forth).
JavaScript:
The createCircle function generates random properties (size, position, and color) for each circle and adds it to the document.
Circles are created at regular intervals (1 second in this case).
Each circle is removed after its animation completes to keep the screen clean and maximize performance.
This full-screen animated screensaver will randomly generate colorful circles that move around the screen without displaying any text. You can simply copy and paste this code into an HTML file and open it in a web browser to see it in action.