好的,下面是一个使用现代CSS技术实现的3D半拟态(Neumorphism)风格的登录页面。这个页面包含了半拟态设计风格、流体动画背景、完整登录表单、微交互动效、粒子背景效果,并且适配暗色和亮色主题。
css
/* styles.css */
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: #f0f0f0; /* Light theme */
color: #333;
font-family: 'Arial', sans-serif;
}
.container {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
.login-box {
position: relative;
z-index: 10;
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
box-shadow: 8px 8px 15px rgba(0, 0, 0, 0.1), -8px -8px 15px rgba(255, 255, 255, 0.1);
border-radius: 15px;
padding: 40px;
text-align: center;
max-width: 400px;
width: 100%;
}
.login-box h2 {
margin-bottom: 30px;
color: #333;
}
.input-box {
margin: 10px 0;
}
.input-box input {
width: calc(100% - 20px);
padding: 10px;
border: none;
border-radius: 10px;
box-shadow: 8px 8px 15px rgba(0, 0, 0, 0.1), -8px -8px 15px rgba(255, 255, 255, 0.1);
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
transition: all 0.3s ease;
}
.input-box input:focus {
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
outline: none;
}
button {
margin-top: 20px;
padding: 10px 20px;
border: none;
border-radius: 10px;
background: rgba(255, 255, 255, 0.1);
box-shadow: 8px 8px 15px rgba(0, 0, 0, 0.1), -8px -8px 15px rgba(255, 255, 255, 0.1);
cursor: pointer;
transition: all 0.3s ease;
}
button:hover {
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}
.background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
.blob {
position: absolute;
background: rgba(255, 255, 255, 0.1);
border-radius: 50%;
filter: blur(80px);
}
/* Dark theme */
body.dark {
background: #121212;
color: #e0e0e0;
}
body.dark .login-box {
background: rgba(0, 0, 0, 0.1);
border-color: rgba(0, 0, 0, 0.1);
}
body.dark .input-box input {
background: rgba(0, 0, 0, 0.1);
}
body.dark button {
background: rgba(0, 0, 0, 0.1);
}
javascript
// script.js
document.addEventListener('DOMContentLoaded', () => {
const blobs = document.querySelectorAll('.blob');
const darkModeToggle = document.createElement('button');
darkModeToggle.innerText = 'Toggle Dark Mode';
darkModeToggle.style.position = 'absolute';
darkModeToggle.style.top = '10px';
darkModeToggle.style.right = '10px';
darkModeToggle.style.zIndex = '20';
document.body.appendChild(darkModeToggle);
darkModeToggle.addEventListener('click', () => {
document.body.classList.toggle('dark');
});
blobs.forEach((blob, index) => {
blob.style.width = `${100 + Math.random() * 100}px`;
blob.style.height = `${100 + Math.random() * 100}px`;
blob.style.top = `${Math.random() * 100}%`;
blob.style.left = `${Math.random() * 100}%`;
blob.style.animation = `move ${5 + Math.random() * 10}s infinite alternate`;
});
const keyframes = `
@keyframes move {
from {
transform: translate(0, 0);
}
to {
transform: translate(${Math.random() * 200}px, ${Math.random() * 200}px);
}
}
`;
const style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = keyframes;
document.head.appendChild(style);
});