HTML美化
霓虹暗黑主题
/* 霓虹暗黑主题变量 */
:root {
--bg-color: #0f0f1b;
--primary: #fc5c7d;
--secondary: #6a82fb;
--text: #e2e8f0;
--accent: #38ef7d;
}
/* 应用主题到容器 */
.theme-container {
background-color: var(--bg-color);
color: var(--text);
border: 1px solid rgba(100, 130, 255, 0.3);
border-radius: 15px;
padding: 30px;
position: relative;
overflow: hidden;
}
/* 创建霓虹背景效果 */
.theme-container::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle,
rgba(252, 92, 125, 0.1) 0%,
rgba(106, 130, 251, 0.05) 40%,
transparent 70%);
animation: rotate 15s linear infinite;
z-index: 0;
}
/* 旋转动画 */
@keyframes rotate {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
/* 按钮样式 */
.neon-button {
background: linear-gradient(135deg, var(--primary), var(--secondary));
color: white;
border: none;
padding: 12px 25px;
border-radius: 50px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
}
.neon-button:hover {
transform: translateY(-3px);
box-shadow: 0 10px 20px rgba(252, 92, 125, 0.3);
}
/* 卡片样式 */
.neon-card {
background: rgba(30, 35, 65, 0.7);
backdrop-filter: blur(10px);
border: 1px solid rgba(100, 130, 255, 0.2);
border-radius: 15px;
padding: 25px;
transition: all 0.3s ease;
}
.neon-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
border-color: var(--primary);
}
简约浅色主题
/* 简约浅色主题变量 */
:root {
--bg-color: #ffffff;
--primary: #4361ee;
--secondary: #3a0ca3;
--text: #2b2d42;
--accent: #f72585;
--card-bg: rgba(255, 255, 255, 0.95);
--border: rgba(0, 0, 0, 0.1);
}
/* 应用主题到容器 */
.theme-container {
background-color: var(--bg-color);
color: var(--text);
border: 1px solid var(--border);
border-radius: 15px;
padding: 30px;
position: relative;
overflow: hidden;
box-shadow: 0 15px 50px rgba(0, 0, 0, 0.05);
}
/* 卡片样式 */
.light-card {
background: var(--card-bg);
border-radius: 15px;
padding: 25px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.03);
border: 1px solid var(--border);
transition: all 0.3s ease;
}
.light-card:hover {
transform: translateY(-5px);
box-shadow: 0 12px 25px rgba(0, 0, 0, 0.08);
}
/* 按钮样式 */
.light-button {
background: linear-gradient(135deg, var(--primary), var(--secondary));
color: white;
border: none;
padding: 12px 25px;
border-radius: 50px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 8px 20px rgba(67, 97, 238, 0.3);
}
.light-button:hover {
transform: translateY(-3px);
box-shadow: 0 12px 25px rgba(67, 97, 238, 0.4);
}
/* 图标样式 */
.light-icon {
width: 70px;
height: 70px;
border-radius: 50%;
background: linear-gradient(135deg, var(--primary), var(--secondary));
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 20px;
font-size: 28px;
color: white;
}
磨砂玻璃效果
/* 基础磨砂玻璃效果 */
.glass-effect {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 10px;
}
/* 带边框光效的磨砂玻璃 */
.glass-with-border {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(15px);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 15px;
box-shadow: 0 0 20px rgba(108, 130, 255, 0.2);
}
/* 彩色磨砂玻璃 */
.colored-glass {
background: linear-gradient(
135deg,
rgba(252, 92, 125, 0.1),
rgba(106, 130, 251, 0.1)
);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 15px;
}
/* 磨砂玻璃卡片 */
.glass-card {
background: rgba(255, 255, 255, 0.08);
backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 15px;
padding: 25px;
transition: all 0.3s ease;
}
.glass-card:hover {
transform: translateY(-5px);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}
/* 磨砂玻璃按钮 */
.glass-button {
background: rgba(108, 130, 255, 0.2);
color: #6a82fb;
padding: 12px 25px;
border-radius: 8px;
border: none;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
backdrop-filter: blur(5px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.glass-button:hover {
background: rgba(108, 130, 255, 0.3);
color: #ffffff;
}
3D卡片翻转效果
/* 3D卡片容器 */
.flip-card {
perspective: 1000px;
aspect-ratio: 3/4; /* 保持宽高比 */
}
/* 卡片元素 */
.feature-card {
height: 100%;
width: 100%;
position: relative;
transform-style: preserve-3d;
transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
/* 卡片悬停时翻转 */
.flip-card:hover .feature-card {
transform: rotateY(180deg);
}
/* 卡片正反面共用样式 */
.card-face {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
border-radius: 15px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 25px;
box-sizing: border-box;
}
/* 卡片正面样式 */
.card-front {
background: rgba(30, 35, 65, 0.7);
backdrop-filter: blur(10px);
border: 1px solid rgba(100, 130, 255, 0.2);
}
/* 卡片背面样式 - 旋转180度隐藏 */
.card-back {
background: linear-gradient(135deg, var(--primary), var(--secondary));
transform: rotateY(180deg);
color: white;
text-align: center;
}
渐变文字动画
/* 基础渐变文字效果 */
.gradient-text {
display: inline-block;
background: linear-gradient(90deg,
#ff0a78,
#7d00ff,
#00a3ff,
#ff0a78);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 300% 300%;
animation: gradientFlow 4s linear infinite;
}
/* 动画关键帧 */
@keyframes gradientFlow {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
/* 应用示例 */
.title-text {
font-size: 32px;
font-weight: 700;
}
.subtitle-text {
font-size: 18px;
font-weight: 500;
}
.feature-title {
font-size: 20px;
font-weight: 600;
}
波浪背景效果
/* 波浪背景效果 */
.wave-bg {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
overflow: hidden;
}
.wave {
position: absolute;
bottom: 0;
left: 0;
width: 200%;
height: 15em;
background: url('data:image/svg+xml;utf8,');
background-size: 50% 100%;
animation: waveAnimation 15s linear infinite;
}
.wave:nth-child(2) {
animation-delay: -5s;
opacity: 0.7;
background: url('data:image/svg+xml;utf8,');
background-size: 50% 100%;
}
.wave:nth-child(3) {
animation-delay: -10s;
opacity: 0.5;
background: url('data:image/svg+xml;utf8,');
background-size: 50% 100%;
}
@keyframes waveAnimation {
0% {
transform: translateX(0);
}
50% {
transform: translateX(-25%);
}
100% {
transform: translateX(-50%);
}
}
动态时钟效果
// 获取时钟指针元素
const hourHand = document.querySelector('.hour-hand');
const minHand = document.querySelector('.min-hand');
const secHand = document.querySelector('.sec-hand');
const digitalClock = document.getElementById('digital-clock');
// 更新时间函数
function updateTime() {
const now = new Date();
const hours = now.getHours();
const minutes = now.getMinutes();
const seconds = now.getSeconds();
// 计算指针角度
const hourDeg = (hours % 12) * 30 + minutes * 0.5; // 每小时30度 + 每分钟0.5度
const minDeg = minutes * 6 + seconds * 0.1; // 每分钟6度 + 每秒0.1度
const secDeg = seconds * 6; // 每秒6度
// 应用旋转角度
hourHand.style.transform = `translateX(-50%) rotate(${hourDeg}deg)`;
minHand.style.transform = `translateX(-50%) rotate(${minDeg}deg)`;
secHand.style.transform = `translateX(-50%) rotate(${secDeg}deg)`;
// 更新数字时钟
const hourStr = hours.toString().padStart(2, '0');
const minStr = minutes.toString().padStart(2, '0');
const secStr = seconds.toString().padStart(2, '0');
digitalClock.textContent = `${hourStr}:${minStr}:${secStr}`;
}
// 每秒更新时间
setInterval(updateTime, 1000);
// 初始化时间
updateTime();