To implement the described interface using HTML and CSS, we'll create a dual scroll wheel time picker with a modern, glassy look. We'll use CSS for styling and JavaScript for the interactive parts like scrolling and snapping.
Here's a basic implementation:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dual Scroll Wheel Time Picker</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<div class="scroll-wheel" id="hoursWheel">
<div class="wheel-content">
<!-- Hours will be dynamically generated -->
</div>
</div>
<div class="scroll-wheel" id="minutesWheel">
<div class="wheel-content">
<!-- Minutes will be dynamically generated -->
</div>
</div>
<button class="lock-button">Lock</button>
</div>
<script src="script.js"></script>
</body>
</html>
CSS (styles.css)
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #000000;
font-family: Arial, sans-serif;
}
.container {
position: relative;
width: 300px;
height: 400px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 10px;
padding: 20px;
}
.scroll-wheel {
position: relative;
width: 100%;
height: 150px;
overflow: hidden;
margin-bottom: 20px;
}
.wheel-content {
position: relative;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transform: translateY(0);
transition: transform 0.3s ease;
}
.wheel-content div {
width: 100%;
text-align: center;
font-size: 24px;
color: #FFFFFF;
padding: 10px 0;
}
.wheel-content div.selected {
font-size: 36px;
font-weight: bold;
}
.wheel-content div.faded {
opacity: 0.5;
border-radius: 10px;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5));
}
.lock-button {
width: 100%;
padding: 15px;
background-color: orange;
color: white;
border: none;
border-radius: 5px;
font-size: 18px;
font-weight: bold;
cursor: pointer;
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.lock-button:hover {
background-color: darkorange;
}
JavaScript (script.js)
document.addEventListener('DOMContentLoaded', () => {
const hoursWheel = document.getElementById('hoursWheel');
const minutesWheel = document.getElementById('minutesWheel');
const hoursContent = hoursWheel.querySelector('.wheel-content');
const minutesContent = minutesWheel.querySelector('.wheel-content');
const generateWheelContent = (container, start, end) => {
let content = '';
for (let i = start; i <= end; i++) {
content += `<div class="wheel-item ${i === 0 ? 'selected' : 'faded'}">${i < 10 ? '0' + i : i}</div>`;
}
container.innerHTML = content;
};
generateWheelContent(hoursContent, 0, 24);
generateWheelContent(minutesContent, 0, 59);
const scrollWheel = (wheel, content, start, end) => {
let currentIndex = 0;
let isScrolling = false;
wheel.addEventListener('wheel', (e) => {
if (isScrolling) return;
isScrolling = true;
const delta = e.deltaY > 0 ? 1 : -1;
currentIndex = (currentIndex + delta + end + 1) % (end + 1);
const items = content.querySelectorAll('.wheel-item');
items.forEach((item, index) => {
item.classList.remove('selected', 'faded');
if (index === currentIndex) {
item.classList.add('selected');
} else {
item.classList.add('faded');
}
});
const offset = (currentIndex - 1) * 40;
content.style.transform = `translateY(${offset}px)`;
setTimeout(() => {
isScrolling = false;
}, 300);
});
};
scrollWheel(hoursWheel, hoursContent, 0, 24);
scrollWheel(minutesWheel, minutesContent, 0, 59);
});
Explanation
- HTML: Defines the structure with two scroll wheels and a lock button.
- CSS: Styles the components with a glassy, modern look using
backdrop-filter and thin white outlines.
- JavaScript: Handles the scrolling and snapping behavior of the scroll wheels.
This implementation provides a basic structure and functionality. You can further enhance it with more sophisticated animations, haptic feedback, and additional features as needed.