This repository has been archived on 2026-06-21. You can view files and clone it, but cannot push or open issues or pull requests.
Files
MetaLab/templates/MetaLab-2026/static/css/home.css
Victor_Jay dae2a38e79 feat: 重构首页模板,双栏现代化布局 + 移动端适配
- 全新 Hero Banner:渐变背景,用户欢迎语
- 左侧最新文章卡片列表,含标题/摘要/作者/日期
- 右侧侧边栏:用户卡片(修复头像显示)、社区统计、快捷入口
- 完全重写 home.css,现代化样式,sticky 侧边栏
- 移动端适配:768px 单列布局,比例缩放
- 后端路由注入 PostService,获取最新 6 篇 approved 文章
2026-05-31 19:51:47 +08:00

438 lines
7.9 KiB
CSS

/* ============================================================
MetaLab Home Styles — 首页专属样式
现代化双栏布局,移动端优先,体验至上
============================================================ */
/* ---------- Hero Banner ---------- */
.hero-banner {
position: relative;
text-align: center;
padding: 3.5rem 1.5rem 3rem;
overflow: hidden;
background: linear-gradient(135deg, #3498db 0%, #2980b9 30%, #2c3e50 100%);
}
.hero-bg {
position: absolute;
inset: 0;
background: radial-gradient(circle at 20% 50%, rgba(255,255,255,.08) 0%, transparent 60%),
radial-gradient(circle at 80% 30%, rgba(255,255,255,.05) 0%, transparent 50%);
pointer-events: none;
}
.hero-content {
position: relative;
z-index: 1;
max-width: 600px;
margin: 0 auto;
}
.hero-title {
font-size: 3.2rem;
font-weight: 800;
color: #fff;
margin-bottom: .5rem;
letter-spacing: -.02em;
line-height: 1.15;
}
.hero-accent {
color: rgba(255,255,255,.65);
font-weight: 700;
}
.hero-tagline {
font-size: 1.15rem;
color: rgba(255,255,255,.75);
font-weight: 400;
margin-bottom: .75rem;
}
.hero-welcome {
font-size: .95rem;
color: rgba(255,255,255,.55);
font-weight: 400;
}
/* ---------- Main Layout ---------- */
.home-main {
padding: 2rem 20px 3rem;
}
.home-grid {
display: grid;
grid-template-columns: 1fr 340px;
gap: 2rem;
align-items: start;
}
/* ---------- Feed (Left) ---------- */
.home-feed {
min-width: 0;
}
.feed-header {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-bottom: 1.25rem;
}
.feed-title {
font-size: 1.35rem;
font-weight: 700;
color: var(--color-primary);
}
.feed-more {
font-size: .88rem;
color: var(--color-accent);
font-weight: 500;
text-decoration: none;
transition: opacity .2s ease;
}
.feed-more:hover {
opacity: .75;
}
/* ---------- Article Cards ---------- */
.article-list {
display: flex;
flex-direction: column;
gap: 1rem;
}
.article-card {
background: var(--color-surface);
border-radius: 10px;
border: 1px solid var(--color-border);
padding: 1.35rem 1.5rem;
transition: box-shadow .2s ease, transform .2s ease;
cursor: default;
}
.article-card:hover {
box-shadow: 0 4px 20px rgba(0,0,0,.08);
transform: translateY(-1px);
}
.article-body {
overflow: hidden;
}
.article-title {
font-size: 1.15rem;
font-weight: 650;
margin-bottom: .45rem;
line-height: 1.4;
}
.article-title a {
color: var(--color-primary);
text-decoration: none;
transition: color .15s ease;
}
.article-title a:hover {
color: var(--color-accent);
}
.article-excerpt {
font-size: .9rem;
color: var(--color-text-light);
line-height: 1.6;
margin-bottom: .75rem;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.article-meta {
display: flex;
align-items: center;
gap: .35rem;
font-size: .82rem;
color: var(--color-secondary);
}
.article-author {
font-weight: 500;
color: var(--color-text-light);
}
.meta-dot {
color: var(--color-border);
}
/* ---------- Empty Feed ---------- */
.empty-feed {
text-align: center;
padding: 3.5rem 1.5rem;
background: var(--color-surface);
border-radius: 10px;
border: 1px solid var(--color-border);
}
.empty-icon {
color: var(--color-border);
margin-bottom: 1rem;
}
.empty-text {
font-size: .95rem;
color: var(--color-text-light);
margin-bottom: 1.25rem;
}
.btn-primary {
display: inline-block;
padding: .6rem 1.8rem;
background: var(--color-accent);
color: #fff;
border-radius: 8px;
font-size: .9rem;
font-weight: 600;
text-decoration: none;
transition: background .2s ease, transform .15s ease;
}
.btn-primary:hover {
background: #2980b9;
transform: translateY(-1px);
}
/* ---------- Sidebar (Right) ---------- */
.home-sidebar {
display: flex;
flex-direction: column;
gap: 1.25rem;
position: sticky;
top: 5rem;
}
.sidebar-card {
background: var(--color-surface);
border-radius: 10px;
border: 1px solid var(--color-border);
padding: 1.35rem 1.5rem;
}
/* --- User Card --- */
.user-card {
text-align: center;
}
.user-avatar-img {
width: 64px;
height: 64px;
border-radius: 50%;
object-fit: cover;
border: 3px solid var(--color-accent);
display: block;
margin: 0 auto .75rem;
}
.user-avatar-fallback {
width: 64px;
height: 64px;
border-radius: 50%;
background: linear-gradient(135deg, var(--color-accent), #2980b9);
color: #fff;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto .75rem;
font-size: 1.6rem;
font-weight: 700;
text-transform: uppercase;
}
.guest-avatar {
background: var(--color-border);
}
.guest-avatar svg {
color: var(--color-text-light);
}
.user-card-name {
font-size: 1.1rem;
font-weight: 650;
color: var(--color-primary);
margin-bottom: .25rem;
word-break: break-all;
}
.user-card-desc {
font-size: .82rem;
color: var(--color-text-light);
margin-bottom: 1rem;
}
.user-card-link {
display: block;
font-size: .85rem;
color: var(--color-accent);
font-weight: 500;
text-decoration: none;
padding: .45rem 0;
border-radius: 6px;
background: rgba(52,152,219,.06);
transition: background .15s ease;
}
.user-card-link:hover {
background: rgba(52,152,219,.12);
}
.btn-login {
display: block;
padding: .55rem 0;
background: var(--color-accent);
color: #fff;
border-radius: 8px;
font-size: .9rem;
font-weight: 600;
text-decoration: none;
transition: background .2s ease, transform .15s ease;
}
.btn-login:hover {
background: #2980b9;
transform: translateY(-1px);
}
/* --- Stats Card --- */
.stats-title {
font-size: .92rem;
font-weight: 650;
color: var(--color-primary);
margin-bottom: .85rem;
}
.stats-grid {
display: flex;
gap: 1rem;
}
.stat-item {
text-align: center;
flex: 1;
}
.stat-value {
display: block;
font-size: 1.5rem;
font-weight: 700;
color: var(--color-accent);
line-height: 1;
margin-bottom: .25rem;
}
.stat-label {
font-size: .78rem;
color: var(--color-text-light);
}
/* --- Links Card --- */
.links-title {
font-size: .92rem;
font-weight: 650;
color: var(--color-primary);
margin-bottom: .75rem;
}
.links-item {
display: flex;
align-items: center;
gap: .6rem;
padding: .55rem .5rem;
font-size: .88rem;
color: var(--color-text-light);
border-radius: 6px;
text-decoration: none;
transition: background .15s ease, color .15s ease;
}
.links-item:hover {
background: var(--color-bg);
color: var(--color-accent);
}
.links-icon {
width: 18px;
height: 18px;
flex-shrink: 0;
}
/* ---------- Responsive ---------- */
@media (max-width: 960px) {
.home-grid {
grid-template-columns: 1fr 280px;
gap: 1.5rem;
}
.hero-title {
font-size: 2.6rem;
}
}
@media (max-width: 768px) {
.hero-banner {
padding: 2.5rem 1.25rem 2.25rem;
}
.hero-title {
font-size: 2.2rem;
}
.hero-tagline {
font-size: 1rem;
}
.home-main {
padding: 1.5rem 16px 2rem;
}
.home-grid {
grid-template-columns: 1fr;
gap: 1.5rem;
}
.home-sidebar {
position: static;
}
.article-card {
padding: 1.1rem 1.2rem;
}
.article-title {
font-size: 1.05rem;
}
}
@media (max-width: 480px) {
.hero-banner {
padding: 2rem 1rem 1.75rem;
}
.hero-title {
font-size: 1.8rem;
}
.hero-welcome {
font-size: .85rem;
}
.feed-title {
font-size: 1.15rem;
}
.home-main {
padding: 1rem 12px 1.5rem;
}
}