Hero 首屏
落地页首屏
实时预览
引入
html
<link rel="stylesheet" href="/tokens/tokens.css">
<link rel="stylesheet" href="/components/hero/hero.css">代码
HTML
html
<!-- Hero Component — 现代落地页首屏 -->
<!-- Demo: Hero 组件 -->
<section class="hero">
<div class="hero__glow hero__glow--primary"></div>
<div class="hero__glow hero__glow--secondary"></div>
<span class="hero__badge">✨ AI-Friendly Design System</span>
<h1 class="hero__title">
你的设计,<br></br>
<span class="hero__title-gradient">AI 来加速</span>
</h1>
<p class="hero__desc">
一套为 AI 编程助手优化的前端组件库。复制即用,零框架依赖,
让 AI 在写代码时有据可依,不再凭空想象。
</p>
<div class="hero__actions">
<button class="btn btn--primary btn--lg">
<svg class="btn__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"></path></svg>
开始使用
</button>
<button class="btn btn--secondary btn--lg">查看组件</button>
</div>
</section>CSS
css
/* Hero.css */
.hero {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: var(--space-24) var(--space-6);
overflow: hidden;
}
/* ── 背景网格 ──────────────────────── */
.hero::before {
content: '';
position: absolute;
inset: 0;
background-image:
linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
background-size: 60px 60px;
mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 30%, transparent 80%);
-webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 30%, transparent 80%);
}
/* ── 光晕效果 ──────────────────────── */
.hero__glow {
position: absolute;
width: 600px;
height: 600px;
border-radius: 50%;
filter: blur(120px);
opacity: 0.15;
pointer-events: none;
}
.hero__glow--primary {
background: var(--color-primary);
top: -200px;
left: 20%;
}
.hero__glow--secondary {
background: var(--color-secondary);
bottom: -200px;
right: 20%;
}
/* ── 内容 ──────────────────────────── */
.hero__badge {
display: inline-flex;
align-items: center;
gap: var(--space-2);
font-size: var(--text-sm);
font-weight: var(--weight-medium);
color: var(--color-primary);
background: var(--color-primary-ghost);
border: 1px solid rgba(99, 102, 241, 0.15);
padding: 6px 16px;
border-radius: var(--radius-full);
margin-bottom: var(--space-6);
position: relative;
}
.hero__badge::before {
content: '';
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--color-primary);
animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
0%, 100% { opacity: 1; transform: scale(1); }
50% { opacity: 0.5; transform: scale(1.5); }
}
.hero__title {
font-family: var(--font-display);
font-size: clamp(var(--text-4xl), 5vw, var(--text-6xl));
font-weight: var(--weight-bold);
color: var(--color-text);
line-height: 1.1;
margin: 0 0 var(--space-6);
position: relative;
max-width: 800px;
}
.hero__title-gradient {
background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.hero__desc {
font-size: var(--text-lg);
color: var(--color-text-secondary);
line-height: var(--leading-relaxed);
margin: 0 0 var(--space-8);
max-width: 560px;
position: relative;
}
.hero__actions {
display: flex;
gap: var(--space-4);
flex-wrap: wrap;
justify-content: center;
position: relative;
}
/* ── 尺寸变体 ──────────────────────── */
.hero--compact {
padding: var(--space-16) var(--space-6);
}
.hero--compact .hero__title {
font-size: clamp(var(--text-2xl), 3vw, var(--text-4xl));
}AI 使用说明
组件名: hero
选择器: .hero
依赖: /tokens/tokens.css
文件: /components/hero/hero.html