The user wants a CSS Grid and Flexbox hybrid layout for a complex web application. This is a technical demonstration, so I should create a visually impressive dashboard-like layout that showcases the power of combining CSS Grid for overall page structure with Flexbox for component-level layouts.
Let me design a modern, sophisticated web application interface that:
-
Grid Structure (Page Level):
- Main grid for the entire app layout
- Sidebar navigation
- Header
- Main content area with nested grids
- Potentially a footer or status bar
-
Flexbox Usage (Component Level):
- Navigation items
- Cards and their internal layouts
- Toolbars and button groups
- Form elements
- Status indicators
-
Visual Design:
- Modern dark theme with high contrast
- NOT the typical purple gradient
- Sophisticated color palette - maybe deep navy/charcoal with cyan/teal accents
- Clean typography
- Subtle animations and interactions
-
Dynamic Elements (at least 3):
- Animated sidebar hover effects
- Card hover animations with scale and glow
- Interactive theme toggle
- Animated data visualization (charts/graphs)
- Smooth page transitions
- Particle/noise background effect
-
Layout Features:
- Responsive design
- Sticky header/sidebar
- Grid areas with names for semantic layout
- Nested grids for complex sections
- Flexbox for alignment and distribution
Let me create a comprehensive dashboard layout that demonstrates this hybrid approach.
CSS Grid + Flexbox Hybrid Layout 设计思路
布局架构
- CSS Grid: 用于页面级宏观布局(侧边栏、头部、主内容区、底部状态栏)
- Flexbox: 用于组件内部微观布局(导航项、卡片内容、工具栏、表单元素)
设计特点
- 深层配色方案: 深炭灰 + 青色/琥珀色双强调色,高对比度
- 动态元素: 流动背景、卡片悬浮动效、侧边栏交互动画、数据可视化动画
- 响应式设计: 自适应不同屏幕尺寸
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nexus Dashboard - Grid + Flexbox Hybrid</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--bg-primary: #0a0e14;
--bg-secondary: #111820;
--bg-tertiary: #1a222d;
--bg-card: #151c26;
--accent-cyan: #00d4aa;
--accent-amber: #ffb347;
--accent-coral: #ff6b6b;
--accent-blue: #4da6ff;
--text-primary: #e8eef4;
--text-secondary: #8b9cb3;
--text-muted: #5a6b7d;
--border-color: #2a3544;
--glow-cyan: rgba(0, 212, 170, 0.3);
--glow-amber: rgba(255, 179, 71, 0.3);
}
body {
font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
background: var(--bg-primary);
color: var(--text-primary);
min-height: 100vh;
overflow-x: hidden;
}
/* === MASTER GRID LAYOUT === */
.app-container {
display: grid;
grid-template-columns: 72px 260px 1fr;
grid-template-rows: 64px 1fr 48px;
grid-template-areas:
"iconbar sidebar header"
"iconbar sidebar main"
"iconbar sidebar footer";
height: 100vh;
position: relative;
}
/* === ANIMATED BACKGROUND === */
.bg-canvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 0;
}
/* === ICON BAR (Grid Area: iconbar) === */
.icon-bar {
grid-area: iconbar;
background: var(--bg-secondary);
border-right: 1px solid var(--border-color);
display: flex;
flex-direction: column;
align-items: center;
padding: 16px 0;
z-index: 10;
}
.icon-bar-logo {
width: 40px;
height: 40px;
background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 18px;
color: var(--bg-primary);
margin-bottom: 32px;
animation: logoPulse 3s ease-in-out infinite;
}
@keyframes logoPulse {
0%, 100% { box-shadow: 0 0 20px var(--glow-cyan); }
50% { box-shadow: 0 0 35px var(--glow-cyan), 0 0 50px var(--glow-cyan); }
}
.icon-bar-nav {
display: flex;
flex-direction: column;
gap: 8px;
flex: 1;
}
.icon-btn {
width: 44px;
height: 44px;
border-radius: 12px;
border: none;
background: transparent;
color: var(--text-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
}
.icon-btn::before {
content: '';
position: absolute;
left: -12px;
width: 3px;
height: 0;
background: var(--accent-cyan);
border-radius: 0 3px 3px 0;
transition: height 0.3s ease;
}
.icon-btn:hover {
background: var(--bg-tertiary);
color: var(--text-primary);
transform: scale(1.08);
}
.icon-btn:hover::before {
height: 24px;
}
.icon-btn.active {
background: rgba(0, 212, 170, 0.15);
color: var(--accent-cyan);
}
.icon-btn.active::before {
height: 24px;
}
.icon-btn svg {
width: 22px;
height: 22px;
}
/* === SIDEBAR (Grid Area: sidebar) === */
.sidebar {
grid-area: sidebar;
background: var(--bg-secondary);
border-right: 1px solid var(--border-color);
display: flex;
flex-direction: column;
overflow: hidden;
z-index: 10;
}
.sidebar-header {
padding: 20px;
border-bottom: 1px solid var(--border-color);
}
.sidebar-title {
font-size: 13px;
text-transform: uppercase;
letter-spacing: 1.5px;
color: var(--text-muted);
margin-bottom: 16px;
}
.search-box {
display: flex;
align-items: center;
background: var(--bg-tertiary);
border-radius: 10px;
padding: 10px 14px;
gap: 10px;
transition: all 0.3s ease;
border: 1px solid transparent;
}
.search-box:focus-within {
border-color: var(--accent-cyan);
box-shadow: 0 0 20px var(--glow-cyan);
}
.search-box svg {
width: 18px;
height: 18px;
color: var(--text-muted);
}
.search-box input {
flex: 1;
background: none;
border: none;
color: var(--text-primary);
font-size: 14px;
outline: none;
}
.search-box input::placeholder {
color: var(--text-muted);
}
.sidebar-nav {
flex: 1;
overflow-y: auto;
padding: 16px 12px;
}
.nav-section {
margin-bottom: 24px;
}
.nav-section-title {
font-size: 11px;
text-transform: uppercase;
letter-spacing: 1.2px;
color: var(--text-muted);
padding: 0 12px;
margin-bottom: 8px;
}
.nav-item {
display: flex;
align-items: center;
padding: 12px 14px;
border-radius: 10px;
color: var(--text-secondary);
cursor: pointer;
transition: all 0.25s ease;
gap: 12px;
margin-bottom: 4px;
}
.nav-item:hover {
background: var(--bg-tertiary);
color: var(--text-primary);
transform: translateX(4px);
}
.nav-item.active {
background: linear-gradient(90deg, rgba(0, 212, 170, 0.15), transparent);
color: var(--accent-cyan);
border-left: 2px solid var(--accent-cyan);
}
.nav-item svg {
width: 18px;
height: 18px;
}
.nav-item-text {
flex: 1;
font-size: 14px;
}
.nav-item-badge {
background: var(--accent-coral);
color: white;
font-size: 11px;
padding: 2px 8px;
border-radius: 10px;
font-weight: 600;
}
.sidebar-footer {
padding: 16px;
border-top: 1px solid var(--border-color);
}
.user-profile {
display: flex;
align-items: center;
gap: 12px;
padding: 10px;
border-radius: 12px;
transition: all 0.3s ease;
cursor: pointer;
}
.user-profile:hover {
background: var(--bg-tertiary);
}
.user-avatar {
width: 40px;
height: 40px;
border-radius: 10px;
background: linear-gradient(135deg, var(--accent-amber), var(--accent-coral));
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
font-size: 14px;
}
.user-info {
flex: 1;
}
.user-name {
font-size: 14px;
font-weight: 500;
}
.user-role {
font-size: 12px;
color: var(--text-muted);
}
/* === HEADER (Grid Area: header) === */
.header {
grid-area: header;
background: var(--bg-secondary);
border-bottom: 1px solid var(--border-color);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px;
z-index: 10;
}
.header-left {
display: flex;
align-items: center;
gap: 20px;
}
.breadcrumb {
display: flex;
align-items: center;
gap: 8px;
font-size: 14px;
}
.breadcrumb-item {
color: var(--text-muted);
}
.breadcrumb-item.current {
color: var(--text-primary);
font-weight: 500;
}
.breadcrumb-separator {
color: var(--text-muted);
}
.header-center {
flex: 1;
display: flex;
justify-content: center;
}
.header-tabs {
display: flex;
background: var(--bg-tertiary);
border-radius: 12px;
padding: 4px;
}
.header-tab {
padding: 8px 20px;
border-radius: 8px;
font-size: 13px;
font-weight: 500;
color: var(--text-secondary);
cursor: pointer;
transition: all 0.3s ease;
border: none;
background: none;
}
.header-tab:hover {
color: var(--text-primary);
}
.header-tab.active {
background: var(--accent-cyan);
color: var(--bg-primary);
}
.header-right {
display: flex;
align-items: center;
gap: 12px;
}
.header-btn {
width: 40px;
height: 40px;
border-radius: 10px;
border: 1px solid var(--border-color);
background: transparent;
color: var(--text-secondary);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
position: relative;
}
.header-btn:hover {
border-color: var(--accent-cyan);
color: var(--accent-cyan);
transform: translateY(-2px);
}
.header-btn svg {
width: 20px;
height: 20px;
}
.notification-dot {
position: absolute;
top: 8px;
right: 8px;
width: 8px;
height: 8px;
background: var(--accent-coral);
border-radius: 50%;
animation: notificationPulse 2s ease-in-out infinite;
}
@keyframes notificationPulse {
0%, 100% { transform: scale(1); opacity: 1; }
50% { transform: scale(1.3); opacity: 0.7; }
}
/* === MAIN CONTENT (Grid Area: main) === */
.main-content {
grid-area: main;
padding: 24px;
overflow-y: auto;
position: relative;
z-index: 5;
}
/* NESTED GRID FOR DASHBOARD */
.dashboard-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: auto auto 1fr;
gap: 20px;
height: 100%;
}
/* Stats Cards Row */
.stat-card {
background: var(--bg-card);
border-radius: 16px;
padding: 20px;
border: 1px solid var(--border-color);
display: flex;
flex-direction: column;
gap: 12px;
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
overflow: hidden;
}
.stat-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3px;
background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
transform: scaleX(0);
transition: transform 0.4s ease;
}
.stat-card:hover {
transform: translateY(-4px);
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
border-color: rgba(0, 212, 170, 0.3);
}
.stat-card:hover::before {
transform: scaleX(1);
}
.stat-card-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
}
.stat-card-icon {
width: 44px;
height: 44px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
}
.stat-card-icon svg {
width: 22px;
height: 22px;
}
.stat-card-icon.cyan {
background: rgba(0, 212, 170, 0.15);
color: var(--accent-cyan);
}
.stat-card-icon.amber {
background: rgba(255, 179, 71, 0.15);
color: var(--accent-amber);
}
.stat-card-icon.coral {
background: rgba(255, 107, 107, 0.15);
color: var(--accent-coral);
}
.stat-card-icon.blue {
background: rgba(77, 166, 255, 0.15);
color: var(--accent-blue);
}
.stat-card-trend {
font-size: 12px;
padding: 4px 8px;
border-radius: 6px;
display: flex;
align-items: center;
gap: 4px;
}
.stat-card-trend.up {
background: rgba(0, 212, 170, 0.15);
color: var(--accent-cyan);
}
.stat-card-trend.down {
background: rgba(255, 107, 107, 0.15);
color: var(--accent-coral);
}
.stat-card-value {
font-size: 32px;
font-weight: 700;
letter-spacing: -0.5px;
}
.stat-card-label {
font-size: 13px;
color: var(--text-secondary);
}
/* Chart Section - Spans 2 columns */
.chart-section {
grid-column: span 2;
background: var(--bg-card);
border-radius: 16px;
border: 1px solid var(--border-color);
padding: 20px;
display: flex;
flex-direction: column;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.section-title {
font-size: 16px;
font-weight: 600;
}
.section-actions {
display: flex;
gap: 8px;
}
.section-btn {
padding: 8px 14px;
border-radius: 8px;
font-size: 12px;
font-weight: 500;
border: 1px solid var(--border-color);
background: transparent;
color: var(--text-secondary);
cursor: pointer;
transition: all 0.3s ease;
}
.section-btn:hover {
border-color: var(--accent-cyan);
color: var(--accent-cyan);
}
.section-btn.active {
background: var(--accent-cyan);
border-color: var(--accent-cyan);
color: var(--bg-primary);
}
.chart-container {
flex: 1;
display: flex;
align-items: flex-end;
justify-content: space-around;
padding: 20px 0;
gap: 12px;
}
.chart-bar-wrapper {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
flex: 1;
}
.chart-bar {
width: 100%;
max-width: 40px;
border-radius: 6px 6px 0 0;
transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
position: relative;
cursor: pointer;
}
.chart-bar::after {
content: attr(data-value);
position: absolute;
top: -24px;
left: 50%;
transform: translateX(-50%);
font-size: 11px;
color: var(--text-primary);
opacity: 0;
transition: opacity 0.3s ease;
}
.chart-bar:hover::after {
opacity: 1;
}
.chart-bar.cyan {
background: linear-gradient(180deg, var(--accent-cyan), rgba(0, 212, 170, 0.3));
}
.chart-bar.amber {
background: linear-gradient(180deg, var(--accent-amber), rgba(255, 179, 71, 0.3));
}
.chart-bar:hover {
filter: brightness(1.2);
transform: scaleY(1.05);
transform-origin: bottom;
}
.chart-label {
font-size: 11px;
color: var(--text-muted);
}
/* Activity List */
.activity-section {
grid-column: span 2;
background: var(--bg-card);
border-radius: 16px;
border: 1px solid var(--border-color);
padding: 20px;
display: flex;
flex-direction: column;
}
.activity-list {
flex: 1;
overflow-y: auto;
}
.activity-item {
display: flex;
align-items: flex-start;
gap: 14px;
padding: 14px 0;
border-bottom: 1px solid var(--border-color);
transition: all 0.3s ease;
}
.activity-item:last-child {
border-bottom: none;
}
.activity-item:hover {
background: var(--bg-tertiary);
margin: 0 -12px;
padding-left: 12px;
padding-right: 12px;
border-radius: 10px;
}
.activity-avatar {
width: 36px;
height: 36px;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: 600;
flex-shrink: 0;
}
.activity-content {
flex: 1;
}
.activity-text {
font-size: 13px;
line-height: 1.5;
}
.activity-text strong {
color: var(--text-primary);
}
.activity-time {
font-size: 11px;
color: var(--text-muted);
margin-top: 4px;
}
/* Data Table - Full Width */
.table-section {
grid-column: span 4;
background: var(--bg-card);
border-radius: 16px;
border: 1px solid var(--border-color);
padding: 20px;
display: flex;
flex-direction: column;
}
.table-toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.table-filter {
display: flex;
gap: 8px;
}
.filter-btn {
padding: 6px 12px;
border-radius: 6px;
font-size: 12px;
border: 1px solid var(--border-color);
background: transparent;
color: var(--text-secondary);
cursor: pointer;
transition: all 0.3s ease;
}
.filter-btn:hover {
border-color: var(--accent-cyan);
color: var(--accent-cyan);
}
.data-table {
width: 100%;
border-collapse: collapse;
}
.data-table th {
text-align: left;
padding: 12px 16px;
font-size: 11px;
text-transform: uppercase;
letter-spacing: 1px;
color: var(--text-muted);
border-bottom: 1px solid var(--border-color);
font-weight: 500;
}
.data-table td {
padding: 14px 16px;
font-size: 13px;
border-bottom: 1px solid var(--border-color);
transition: all 0.3s ease;
}
.data-table tbody tr {
transition: all 0.3s ease;
}
.data-table tbody tr:hover {
background: var(--bg-tertiary);
}
.data-table tbody tr:hover td {
border-bottom-color: transparent;
}
.table-project {
display: flex;
align-items: center;
gap: 12px;
}
.project-icon {
width: 32px;
height: 32px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
}
.status-badge {
padding: 4px 10px;
border-radius: 6px;
font-size: 11px;
font-weight: 500;
}
.status-badge.active {
background: rgba(0, 212, 170, 0.15);
color: var(--accent-cyan);
}
.status-badge.pending {
background: rgba(255, 179, 71, 0.15);
color: var(--accent-amber);
}
.status-badge.inactive {
background: rgba(255, 107, 107, 0.15);
color: var(--accent-coral);
}
.progress-bar {
width: 100px;
height: 6px;
background: var(--bg-tertiary);
border-radius: 3px;
overflow: hidden;
}
.progress-fill {
height: 100%;
border-radius: 3px;
transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-fill.cyan {
background: var(--accent-cyan);
}
.progress-fill.amber {
background: var(--accent-amber);
}
.progress-fill.coral {
background: var(--accent-coral);
}
/* === FOOTER (Grid Area: footer) === */
.footer {
grid-area: footer;
background: var(--bg-secondary);
border-top: 1px solid var(--border-color);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px;
font-size: 12px;
color: var(--text-muted);
z-index: 10;
}
.footer-left {
display: flex;
align-items: center;
gap: 20px;
}
.footer-status {
display: flex;
align-items: center;
gap: 8px;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent-cyan);
animation: statusBlink 2s ease-in-out infinite;
}
@keyframes statusBlink {
0%, 100% { opacity: 1; }
50% { opacity: 0.4; }
}
.footer-right {
display: flex;
align-items: center;
gap: 16px;
}
.footer-link {
color: var(--text-muted);
text-decoration: none;
transition: color 0.3s ease;
}
.footer-link:hover {
color: var(--accent-cyan);
}
/* === RESPONSIVE === */
@media (max-width: 1400px) {
.dashboard-grid {
grid-template-columns: repeat(2, 1fr);
}
.table-section {
grid-column: span 2;
}
}
@media (max-width: 1100px) {
.app-container {
grid-template-columns: 72px 1fr;
grid-template-areas:
"iconbar header"
"iconbar main"
"iconbar footer";
}
.sidebar {
position: fixed;
left: -280px;
top: 0;
height: 100vh;
width: 280px;
z-index: 100;
transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.open {
left: 72px;
}
.dashboard-grid {
grid-template-columns: 1fr;
}
.chart-section,
.activity-section,
.table-section {
grid-column: span 1;
}
}
@media (max-width: 768px) {
.app-container {
grid-template-columns: 1fr;
grid-template-areas:
"header"
"main"
"footer";
}
.icon-bar {
display: none;
}
.header-center {
display: none;
}
}
/* === SCROLLBAR === */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: var(--bg-tertiary);
}
::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--text-muted);
}
</style>
</head>
<body>
<canvas class="bg-canvas" id="bgCanvas"></canvas>
<div class="app-container">
<!-- Icon Bar -->
<nav class="icon-bar">
<div class="icon-bar-logo">N</div>
<div class="icon-bar-nav">
<button class="icon-btn active" title="Dashboard">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="7" height="7" rx="1"/>
<rect x="14" y="3" width="7" height="7" rx="1"/>
<rect x="3" y="14" width="7" height="7" rx="1"/>
<rect x="14" y="14" width="7" height="7" rx="1"/>
</svg>
</button>
<button class="icon-btn" title="Analytics">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M3 3v18h18"/>
<path d="M18 17V9"/>
<path d="M13 17V5"/>
<path d="M8 17v-3"/>
</svg>
</button>
<button class="icon-btn" title="Projects">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
</svg>
</button>
<button class="icon-btn" title="Team">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
<circle cx="9" cy="7" r="4"/>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
</svg>
</button>
<button class="icon-btn" title="Calendar">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>
<line x1="16" y1="2" x2="16" y2="6"/>
<line x1="8" y1="2" x2="8" y2="6"/>
<line x1="3" y1="10" x2="21" y2="10"/>
</svg>
</button>
</div>
<button class="icon-btn" title="Settings">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"/>
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>
</svg>
</button>
</nav>
<!-- Sidebar -->
<aside class="sidebar" id="sidebar">
<div class="sidebar-header">
<div class="sidebar-title">Navigation</div>
<div class="search-box">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"/>
<path d="M21 21l-4.35-4.35"/>
</svg>
<input type="text" placeholder="Search anything...">
</div>
</div>
<nav class="sidebar-nav">
<div class="nav-section">
<div class="nav-section-title">Main Menu</div>
<div class="nav-item active">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>
<polyline points="9 22 9 12 15 12 15 22"/>
</svg>
<span class="nav-item-text">Dashboard</span>
</div>
<div class="nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>
</svg>
<span class="nav-item-text">Analytics</span>
<span class="nav-item-badge">New</span>
</div>
<div class="nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
</svg>
<span class="nav-item-text">Reports</span>
</div>
</div>
<div class="nav-section">
<div class="nav-section-title">Workspace</div>
<div class="nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
</svg>
<span class="nav-item-text">Projects</span>
<span class="nav-item-badge">12</span>
</div>
<div class="nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
<line x1="9" y1="9" x2="15" y2="9"/>
<line x1="9" y1="15" x2="15" y2="15"/>
</svg>
<span class="nav-item-text">Tasks</span>
</div>
<div class="nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
</svg>
<span class="nav-item-text">Messages</span>
<span class="nav-item-badge">5</span>
</div>
</div>
<div class="nav-section">
<div class="nav-section-title">Account</div>
<div class="nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>
<circle cx="12" cy="7" r="4"/>
</svg>
<span class="nav-item-text">Profile</span>
</div>
<div class="nav-item">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="3"/>
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>
</svg>
<span class="nav-item-text">Settings</span>
</div>
</div>
</nav>
<div class="sidebar-footer">
<div class="user-profile">
<div class="user-avatar">AK</div>
<div class="user-info">
<div class="user-name">Alex Kim</div>
<div class="user-role">Administrator</div>
</div>
</div>
</div>
</aside>
<!-- Header -->
<header class="header">
<div class="header-left">
<div class="breadcrumb">
<span class="breadcrumb-item">Home</span>
<span class="breadcrumb-separator">/</span>
<span class="breadcrumb-item current">Dashboard</span>
</div>
</div>
<div class="header-center">
<div class="header-tabs">
<button class="header-tab active">Overview</button>
<button class="header-tab">Analytics</button>
<button class="header-tab">Reports</button>
</div>
</div>
<div class="header-right">
<button class="header-btn">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/>
<path d="M13.73 21a2 2 0 0 1-3.46 0"/>
</svg>
<span class="notification-dot"></span>
</button>
<button class="header-btn">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/>
<line x1="12" y1="17" x2="12.01" y2="17"/>
</svg>
</button>
</div>
</header>
<!-- Main Content -->
<main class="main-content">
<div class="dashboard-grid">
<!-- Stat Cards -->
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-icon cyan">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
<circle cx="9" cy="7" r="4"/>
<path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
</svg>
</div>
<div class="stat-card-trend up">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/>
</svg>
+12.5%
</div>
</div>
<div class="stat-card-value">24,589</div>
<div class="stat-card-label">Total Users</div>
</div>
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-icon amber">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="2" y="7" width="20" height="14" rx="2" ry="2"/>
<path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"/>
</svg>
</div>
<div class="stat-card-trend up">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/>
</svg>
+8.2%
</div>
</div>
<div class="stat-card-value">1,284</div>
<div class="stat-card-label">Active Projects</div>
</div>
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-icon coral">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<polyline points="12 6 12 12 16 14"/>
</svg>
</div>
<div class="stat-card-trend down">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="23 18 13.5 8.5 8.5 13.5 1 6"/>
</svg>
-3.1%
</div>
</div>
<div class="stat-card-value">847h</div>
<div class="stat-card-label">Hours Tracked</div>
</div>
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-icon blue">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="12" y1="1" x2="12" y2="23"/>
<path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>
</svg>
</div>
<div class="stat-card-trend up">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="23 6 13.5 15.5 8.5 10.5 1 18"/>
</svg>
+24.8%
</div>
</div>
<div class="stat-card-value">$128.5K</div>
<div class="stat-card-label">Revenue</div>
</div>
<!-- Chart Section -->
<section class="chart-section">
<div class="section-header">
<h2 class="section-title">Performance Overview</h2>
<div class="section-actions">
<button class="section-btn active">Week</button>
<button class="section-btn">Month</button>
<button class="section-btn">Year</button>
</div>
</div>
<div class="chart-container" id="chartContainer">
<!-- Bars generated by JS -->
</div>
</section>
<!-- Activity Section -->
<section class="activity-section">
<div class="section-header">
<h2 class="section-title">Recent Activity</h2>
<button class="section-btn">View All</button>
</div>
<div class="activity-list">
<div class="activity-item">
<div class="activity-avatar" style="background: linear-gradient(135deg, #00d4aa, #4da6ff);">SK</div>
<div class="activity-content">
<div class="activity-text"><strong>Sarah Kim</strong> completed task "UI Design Review" in Project Nexus</div>
<div class="activity-time">2 minutes ago</div>
</div>
</div>
<div class="activity-item">
<div class="activity-avatar" style="background: linear-gradient(135deg, #ffb347, #ff6b6b);">MJ</div>
<div class="activity-content">
<div class="activity-text"><strong>Mike Johnson</strong> uploaded 3 new files to Documentation</div>
<div class="activity-time">15 minutes ago</div>
</div>
</div>
<div class="activity-item">
<div class="activity-avatar" style="background: linear-gradient(135deg, #4da6ff, #00d4aa);">EW</div>
<div class="activity-content">
<div class="activity-text"><strong>Emma Wilson</strong> created a new branch "feature/auth-flow"</div>
<div class="activity-time">1 hour ago</div>
</div>
</div>
<div class="activity-item">
<div class="activity-avatar" style="background: linear-gradient(135deg, #ff6b6b, #ffb347);">JL</div>
<div class="activity-content">
<div class="activity-text"><strong>James Lee</strong> merged pull request #247 to main</div>
<div class="activity-time">2 hours ago</div>
</div>
</div>
<div class="activity-item">
<div class="activity-avatar" style="background: linear-gradient(135deg, #00d4aa, #ffb347);">AC</div>
<div class="activity-content">
<div class="activity-text"><strong>Anna Chen</strong> commented on issue #189</div>
<div class="activity-time">3 hours ago</div>
</div>
</div>
</div>
</section>
<!-- Table Section -->
<section class="table-section">
<div class="table-toolbar">
<h2 class="section-title">Active Projects</h2>
<div class="table-filter">
<button class="filter-btn">All</button>
<button class="filter-btn">Active</button>
<button class="filter-btn">Pending</button>
</div>
</div>
<table class="data-table">
<thead>
<tr>
<th>Project</th>
<th>Team</th>
<th>Status</th>
<th>Progress</th>
<th>Budget</th>
</tr>
</thead>
<tbody id="tableBody">
<!-- Generated by JS -->
</tbody>
</table>
</section>
</div>
</main>
<!-- Footer -->
<footer class="footer">
<div class="footer-left">
<div class="footer-status">
<span class="status-dot"></span>
<span>All systems operational</span>
</div>
<span>Version 2.4.1</span>
</div>
<div class="footer-right">
<a href="#" class="footer-link">Documentation</a>
<a href="#" class="footer-link">Support</a>
<a href="#" class="footer-link">API Status</a>
<span>2024 Nexus Dashboard</span>
</div>
</footer>
</div>
<script>
// === ANIMATED BACKGROUND ===
const canvas = document.getElementById('bgCanvas');
const ctx = canvas.getContext('2d');
let particles = [];
let animationId;
function resizeCanvas() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
class Particle {
constructor() {
this.reset();
}
reset() {
this.x = Math.random() * canvas.width;
this.y = Math.random() * canvas.height;
this.size = Math.random() * 2 + 0.5;
this.speedX = (Math.random() - 0.5) * 0.3;
this.speedY = (Math.random() - 0.5) * 0.3;
this.opacity = Math.random() * 0.5 + 0.1;
this.hue = Math.random() > 0.5 ? 165 : 38; // Cyan or Amber
}
update() {
this.x += this.speedX;
this.y += this.speedY;
if (this.x < 0 || this.x > canvas.width) this.speedX *= -1;
if (this.y < 0 || this.y > canvas.height) this.speedY *= -1;
}
draw() {
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fillStyle = `hsla(${this.hue}, 80%, 60%, ${this.opacity})`;
ctx.fill();
}
}
function initParticles() {
particles = [];
const count = Math.min(80, Math.floor((canvas.width * canvas.height) / 15000));
for (let i = 0; i < count; i++) {
particles.push(new Particle());
}
}
function drawConnections() {
for (let i = 0; i < particles.length; i++) {
for (let j = i + 1; j < particles.length; j++) {
const dx = particles[i].x - particles[j].x;
const dy = particles[i].y - particles[j].y;
const distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 120) {
ctx.beginPath();
ctx.moveTo(particles[i].x, particles[i].y);
ctx.lineTo(particles[j].x, particles[j].y);
ctx.strokeStyle = `rgba(0, 212, 170, ${0.08 * (1 - distance / 120)})`;
ctx.lineWidth = 0.5;
ctx.stroke();
}
}
}
}
function animateBackground() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Gradient background
const gradient = ctx.createRadialGradient(
canvas.width * 0.3, canvas.height * 0.3, 0,
canvas.width * 0.5, canvas.height * 0.5, canvas.width * 0.8
);
gradient.addColorStop(0, '#111820');
gradient.addColorStop(1, '#0a0e14');
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, canvas.width, canvas.height);
drawConnections();
particles.forEach(p => {
p.update();
p.draw();
});
animationId = requestAnimationFrame(animateBackground);
}
resizeCanvas();
initParticles();
animateBackground();
window.addEventListener('resize', () => {
resizeCanvas();
initParticles();
});
// === CHART ANIMATION ===
const chartData = [
{ label: 'Mon', value: 65, type: 'cyan' },
{ label: 'Tue', value: 85, type: 'amber' },
{ label: 'Wed', value: 45, type: 'cyan' },
{ label: 'Thu', value: 92, type: 'amber' },
{ label: 'Fri', value: 78, type: 'cyan' },
{ label: 'Sat', value: 55, type: 'amber' },
{ label: 'Sun', value: 88, type: 'cyan' }
];
function animateChart() {
const container = document.getElementById('chartContainer');
container.innerHTML = '';
chartData.forEach((item, index) => {
const wrapper = document.createElement('div');
wrapper.className = 'chart-bar-wrapper';
const bar = document.createElement('div');
bar.className = `chart-bar ${item.type}`;
bar.setAttribute('data-value', item.value + '%');
bar.style.height = '0%';
const label = document.createElement('span');
label.className = 'chart-label';
label.textContent = item.label;
wrapper.appendChild(bar);
wrapper.appendChild(label);
container.appendChild(wrapper);
setTimeout(() => {
bar.style.height = item.value + '%';
}, index * 100);
});
}
// === TABLE DATA ===
const tableData = [
{ name: 'Nexus Platform', team: 'Frontend', status: 'active', progress: 78, budget: '$45,000', color: '#00d4aa' },
{ name: 'Data Pipeline', team: 'Backend', status: 'active', progress: 92, budget: '$32,000', color: '#4da6ff' },
{ name: 'Mobile App v2', team: 'Mobile', status: 'pending', progress: 45, budget: '$28,000', color: '#ffb347' },
{ name: 'API Gateway', team: 'DevOps', status: 'active', progress: 65, budget: '$18,500', color: '#00d4aa' },
{ name: 'Analytics Dashboard', team: 'Data', status: 'pending', progress: 30, budget: '$24,000', color: '#ff6b6b' }
];
function renderTable() {
const tbody = document.getElementById('tableBody');
tbody.innerHTML = '';
tableData.forEach((item, index) => {
const row = document.createElement('tr');
const progressClass = item.progress > 70 ? 'cyan' : item.progress > 40 ? 'amber' : 'coral';
row.innerHTML = `
<td>
<div class="table-project">
<div class="project-icon" style="background: ${item.color}20; color: ${item.color}">
${item.name.charAt(0)}
</div>
<span>${item.name}</span>
</div>
</td>
<td>${item.team}</td>
<td><span class="status-badge ${item.status}">${item.status.charAt(0).toUpperCase() + item.status.slice(1)}</span></td>
<td>
<div class="progress-bar">
<div class="progress-fill ${progressClass}" style="width: 0%"></div>
</div>
</td>
<td>${item.budget}</td>
`;
tbody.appendChild(row);
// Animate progress bar
setTimeout(() => {
row.querySelector('.progress-fill').style.width = item.progress + '%';
}, index * 150);
});
}
// === INTERACTIONS ===
// Header tabs
document.querySelectorAll('.header-tab').forEach(tab => {
tab.addEventListener('click', function() {
document.querySelectorAll('.header-tab').forEach(t => t.classList.remove('active'));
this.classList.add('active');
});
});
// Section buttons
document.querySelectorAll('.section-actions .section-btn').forEach(btn => {
btn.addEventListener('click', function() {
this.parentElement.querySelectorAll('.section-btn').forEach(b => b.classList.remove('active'));
this.classList.add('active');
});
});
// Nav items
document.querySelectorAll('.nav-item').forEach(item => {
item.addEventListener('click', function() {
document.querySelectorAll('.nav-item').forEach(n => n.classList.remove('active'));
this.classList.add('active');
});
});
// Icon buttons
document.querySelectorAll('.icon-btn').forEach(btn => {
btn.addEventListener('click', function() {
if (this.parentElement.classList.contains('icon-bar-nav')) {
this.parentElement.querySelectorAll('.icon-btn').forEach(b => b.classList.remove('active'));
this.classList.add('active');
}
});
});
// Filter buttons
document.querySelectorAll('.filter-btn').forEach((btn, index) => {
btn.addEventListener('click', function() {
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
this.classList.add('active');
});
});
// Stat card hover effect
document.querySelectorAll('.stat-card').forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-4px) scale(1.02)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
// Initialize
animateChart();
renderTable();
// Periodic chart refresh animation
setInterval(() => {
chartData.forEach(item => {
item.value = Math.floor(Math.random() * 50) + 40;
});
animateChart();
}, 5000);
</script>
</body>
</html>
布局结构解析
CSS Grid 用于宏观布局
grid-template-areas:
"iconbar sidebar header"
"iconbar sidebar main"
"iconbar sidebar footer"
- 三列布局:图标栏(72px) + 侧边栏(260px) + 主内容区(1fr)
- 三行布局:头部(64px) + 主内容(1fr) + 底部(48px)
Flexbox 用于微观布局
- 图标栏: 垂直排列的导航按钮
- 侧边栏: 搜索框、导航项、用户信息
- 头部: 面包屑、标签页、操作按钮
- 卡片内部: 图标、数据、趋势指示器
- 表格行: 项目信息、状态、进度条
动态效果
- 粒子背景: 带连线的流动粒子系统
- 图表动画: 柱状图逐个升起
- 进度条动画: 表格中的进度条渐进填充
- 悬浮动效: 卡片抬升、按钮缩放、发光效果
- 实时数据刷新: 每5秒自动刷新图表数据