The user wants me to build a CSS grid-based responsive pricing table with interactive hover effects and tooltips. Let me create something visually striking and modern, avoiding the typical bland pricing table designs.
Let me plan:
-
Design Aesthetic:
- Going for a dark, technical/futuristic vibe
- Using a distinctive font - maybe Space Grotesk or JetBrains Mono for that tech feel
- Color scheme: Dark background with a vibrant accent (electric cyan or lime green)
- Subtle grid/pattern background for depth
-
Layout:
- CSS Grid for the pricing cards
- 3 pricing tiers (standard setup)
- Responsive: stack on mobile, 3 columns on desktop
- Featured/popular card with visual distinction
-
Interactive Elements:
- Hover effects on cards (lift, glow, border animation)
- Tooltips on feature items explaining what they mean
- Button hover effects
- Staggered entrance animation
- Maybe a toggle for monthly/yearly pricing
-
Tooltips:
- Custom CSS tooltips (not title attribute)
- Appear on hover with smooth animation
- Positioned smartly
-
Polish:
- Consistent spacing
- Clear visual hierarchy
- Accessible (focus states, ARIA labels)
- Reduced motion support
Let me write this:
响应式定价表格
我将创建一个具有技术感的深色主题定价表格,包含网格布局、悬停动效和自定义工具提示。
设计思路:
- 深色科技风格,配合电光青色强调色
- Space Grotesk 作为标题字体,营造现代技术感
- CSS Grid 实现响应式三列布局
- 自定义工具提示展示功能详情
- 悬停时卡片提升+发光效果
- 月付/年付切换功能
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>定价方案</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0a0f;
--bg-elevated: #12121a;
--card: #16161f;
--card-hover: #1c1c28;
--border: #2a2a3a;
--border-accent: #00d4aa;
--fg: #e8e8ed;
--muted: #6b6b7b;
--accent: #00d4aa;
--accent-glow: rgba(0, 212, 170, 0.3);
--secondary: #7c3aed;
}
* {
box-sizing: border-box;
}
body {
font-family: 'IBM Plex Mono', monospace;
background-color: var(--bg);
color: var(--fg);
min-height: 100vh;
margin: 0;
overflow-x: hidden;
}
.font-display {
font-family: 'Space Grotesk', sans-serif;
}
/* Background grid pattern */
.bg-grid {
background-image:
linear-gradient(rgba(0, 212, 170, 0.03) 1px, transparent 1px),
linear-gradient(90deg, rgba(0, 212, 170, 0.03) 1px, transparent 1px);
background-size: 60px 60px;
background-position: center center;
}
/* Gradient orbs */
.orb {
position: absolute;
border-radius: 50%;
filter: blur(80px);
opacity: 0.5;
pointer-events: none;
}
.orb-1 {
width: 400px;
height: 400px;
background: var(--accent);
top: -100px;
left: -100px;
opacity: 0.15;
}
.orb-2 {
width: 300px;
height: 300px;
background: var(--secondary);
bottom: 10%;
right: -50px;
opacity: 0.1;
}
/* Toggle Switch */
.toggle-container {
display: flex;
align-items: center;
gap: 1rem;
justify-content: center;
}
.toggle-btn {
padding: 0.5rem 1rem;
background: transparent;
border: none;
color: var(--muted);
cursor: pointer;
font-family: inherit;
font-size: 0.875rem;
transition: color 0.3s ease;
}
.toggle-btn.active {
color: var(--accent);
}
.toggle-switch {
width: 56px;
height: 28px;
background: var(--border);
border-radius: 999px;
position: relative;
cursor: pointer;
transition: background 0.3s ease;
}
.toggle-switch::after {
content: '';
position: absolute;
width: 22px;
height: 22px;
background: var(--accent);
border-radius: 50%;
top: 3px;
left: 3px;
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.toggle-switch.yearly::after {
transform: translateX(28px);
}
.save-badge {
background: var(--accent);
color: var(--bg);
font-size: 0.625rem;
padding: 0.125rem 0.5rem;
border-radius: 999px;
font-weight: 500;
letter-spacing: 0.05em;
}
/* Pricing Grid */
.pricing-grid {
display: grid;
grid-template-columns: 1fr;
gap: 1.5rem;
max-width: 1200px;
margin: 0 auto;
padding: 0 1.5rem;
}
@media (min-width: 768px) {
.pricing-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 1024px) {
.pricing-grid {
grid-template-columns: repeat(3, 1fr);
gap: 2rem;
}
}
/* Pricing Card */
.pricing-card {
background: var(--card);
border: 1px solid var(--border);
border-radius: 16px;
padding: 2rem;
position: relative;
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
opacity: 0;
transform: translateY(30px);
}
.pricing-card.visible {
opacity: 1;
transform: translateY(0);
}
.pricing-card:hover {
background: var(--card-hover);
transform: translateY(-8px);
border-color: var(--border-accent);
box-shadow:
0 20px 40px rgba(0, 0, 0, 0.4),
0 0 60px var(--accent-glow);
}
.pricing-card.featured {
border-color: var(--accent);
background: linear-gradient(180deg, rgba(0, 212, 170, 0.08) 0%, var(--card) 100%);
}
.pricing-card.featured:hover {
box-shadow:
0 25px 50px rgba(0, 0, 0, 0.5),
0 0 80px var(--accent-glow);
}
.featured-badge {
position: absolute;
top: -12px;
left: 50%;
transform: translateX(-50%);
background: var(--accent);
color: var(--bg);
font-size: 0.75rem;
font-weight: 700;
padding: 0.25rem 1rem;
border-radius: 999px;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.card-header {
text-align: center;
padding-bottom: 1.5rem;
border-bottom: 1px solid var(--border);
margin-bottom: 1.5rem;
}
.plan-name {
font-size: 1.25rem;
font-weight: 700;
margin-bottom: 0.5rem;
letter-spacing: -0.02em;
}
.plan-description {
color: var(--muted);
font-size: 0.875rem;
line-height: 1.5;
}
.price-container {
display: flex;
align-items: baseline;
justify-content: center;
gap: 0.25rem;
margin: 1.5rem 0;
}
.currency {
font-size: 1.5rem;
color: var(--muted);
}
.price {
font-size: 4rem;
font-weight: 700;
line-height: 1;
letter-spacing: -0.04em;
}
.period {
color: var(--muted);
font-size: 0.875rem;
margin-left: 0.5rem;
}
/* CTA Button */
.cta-btn {
width: 100%;
padding: 1rem 1.5rem;
border-radius: 10px;
font-family: inherit;
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.cta-btn.primary {
background: var(--accent);
color: var(--bg);
border: none;
}
.cta-btn.primary:hover {
box-shadow: 0 0 30px var(--accent-glow);
transform: scale(1.02);
}
.cta-btn.secondary {
background: transparent;
color: var(--fg);
border: 1px solid var(--border);
}
.cta-btn.secondary:hover {
border-color: var(--accent);
color: var(--accent);
}
.cta-btn:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
/* Features List */
.features-list {
margin-top: 1.5rem;
display: flex;
flex-direction: column;
gap: 0.875rem;
}
.feature-item {
display: flex;
align-items: center;
gap: 0.75rem;
position: relative;
}
.feature-icon {
width: 20px;
height: 20px;
flex-shrink: 0;
color: var(--accent);
}
.feature-text {
font-size: 0.875rem;
color: var(--fg);
}
.feature-text.disabled {
color: var(--muted);
text-decoration: line-through;
}
/* Tooltip */
.tooltip-trigger {
position: relative;
cursor: help;
}
.tooltip-trigger::after {
content: '?';
display: inline-flex;
align-items: center;
justify-content: center;
width: 14px;
height: 14px;
font-size: 0.625rem;
background: var(--border);
border-radius: 50%;
margin-left: 0.375rem;
color: var(--muted);
transition: all 0.2s ease;
}
.tooltip-trigger:hover::after {
background: var(--accent);
color: var(--bg);
}
.tooltip-content {
position: absolute;
bottom: calc(100% + 10px);
left: 50%;
transform: translateX(-50%) translateY(5px);
background: var(--bg-elevated);
border: 1px solid var(--border);
border-radius: 8px;
padding: 0.75rem 1rem;
font-size: 0.75rem;
line-height: 1.5;
color: var(--muted);
width: 200px;
opacity: 0;
visibility: hidden;
transition: all 0.2s ease;
z-index: 100;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.tooltip-content::after {
content: '';
position: absolute;
top: 100%;
left: 50%;
transform: translateX(-50%);
border: 6px solid transparent;
border-top-color: var(--border);
}
.tooltip-trigger:hover .tooltip-content {
opacity: 1;
visibility: visible;
transform: translateX(-50%) translateY(0);
}
/* Responsive adjustments */
@media (max-width: 767px) {
.price {
font-size: 3rem;
}
.pricing-card {
padding: 1.5rem;
}
}
/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
.pricing-card,
.cta-btn,
.toggle-switch::after,
.tooltip-content {
transition: none;
}
.pricing-card:hover {
transform: none;
}
}
/* Stagger animation delays */
.pricing-card:nth-child(1) { transition-delay: 0.1s; }
.pricing-card:nth-child(2) { transition-delay: 0.2s; }
.pricing-card:nth-child(3) { transition-delay: 0.3s; }
</style>
</head>
<body class="bg-grid">
<!-- Background orbs -->
<div class="orb orb-1"></div>
<div class="orb orb-2"></div>
<main class="relative py-16 md:py-24">
<!-- Header -->
<header class="text-center mb-12 md:mb-16 px-4">
<h1 class="font-display text-4xl md:text-5xl lg:text-6xl font-bold tracking-tight mb-4">
选择你的方案
</h1>
<p class="text-[var(--muted)] text-lg md:text-xl max-w-2xl mx-auto">
从个人开发者到企业团队,总有一款适合你
</p>
<!-- Billing Toggle -->
<div class="toggle-container mt-8">
<button class="toggle-btn active" id="monthlyBtn" aria-label="月付">月付</button>
<div class="toggle-switch" id="billingToggle" role="switch" aria-checked="false" tabindex="0"></div>
<button class="toggle-btn" id="yearlyBtn" aria-label="年付">年付</button>
<span class="save-badge">省 20%</span>
</div>
</header>
<!-- Pricing Grid -->
<div class="pricing-grid">
<!-- Starter Plan -->
<article class="pricing-card" data-monthly="0" data-yearly="0">
<div class="card-header">
<h2 class="plan-name font-display">Starter</h2>
<p class="plan-description">适合个人项目和学习使用</p>
</div>
<div class="price-container">
<span class="currency">¥</span>
<span class="price font-display">0</span>
<span class="period">/月</span>
</div>
<button class="cta-btn secondary" aria-label="开始使用 Starter 方案">
免费开始
</button>
<ul class="features-list" role="list">
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text">最多 3 个项目</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text">1GB 存储空间</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text">社区支持</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text tooltip-trigger">
基础分析
<div class="tooltip-content">包含访问量、页面浏览量等基础数据统计</div>
</span>
</li>
<li class="feature-item">
<span class="feature-icon" style="color: var(--muted);">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</span>
<span class="feature-text disabled">自定义域名</span>
</li>
</ul>
</article>
<!-- Pro Plan (Featured) -->
<article class="pricing-card featured" data-monthly="99" data-yearly="79">
<div class="featured-badge font-display">最受欢迎</div>
<div class="card-header">
<h2 class="plan-name font-display">Pro</h2>
<p class="plan-description">专业开发者的最佳选择</p>
</div>
<div class="price-container">
<span class="currency">¥</span>
<span class="price font-display">99</span>
<span class="period">/月</span>
</div>
<button class="cta-btn primary" aria-label="开始使用 Pro 方案">
立即升级
</button>
<ul class="features-list" role="list">
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text">无限项目</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text">50GB 存储空间</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text">优先邮件支持</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text tooltip-trigger">
高级分析
<div class="tooltip-content">包含用户行为分析、转化漏斗、A/B测试等高级功能</div>
</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text tooltip-trigger">
自定义域名
<div class="tooltip-content">绑定你自己的域名,支持SSL证书自动配置</div>
</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text">API 访问</span>
</li>
</ul>
</article>
<!-- Enterprise Plan -->
<article class="pricing-card" data-monthly="299" data-yearly="239">
<div class="card-header">
<h2 class="plan-name font-display">Enterprise</h2>
<p class="plan-description">为大型团队量身定制</p>
</div>
<div class="price-container">
<span class="currency">¥</span>
<span class="price font-display">299</span>
<span class="period">/月</span>
</div>
<button class="cta-btn secondary" aria-label="联系销售获取 Enterprise 方案">
联系销售
</button>
<ul class="features-list" role="list">
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text">Pro 的所有功能</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text">无限存储空间</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text tooltip-trigger">
专属客户经理
<div class="tooltip-content">一对一技术支持,响应时间不超过4小时</div>
</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text tooltip-trigger">
SSO 单点登录
<div class="tooltip-content">支持 SAML 2.0、OAuth 等企业级身份认证</div>
</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text">SLA 保障</span>
</li>
<li class="feature-item">
<svg class="feature-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
<polyline points="20 6 9 17 4 12"></polyline>
</svg>
<span class="feature-text tooltip-trigger">
私有部署选项
<div class="tooltip-content">支持本地服务器或私有云部署</div>
</span>
</li>
</ul>
</article>
</div>
<!-- Footer note -->
<p class="text-center text-[var(--muted)] text-sm mt-12 px-4">
所有方案均支持 14 天免费试用,无需信用卡
</p>
</main>
<script>
// Initialize variables first
const cards = document.querySelectorAll('.pricing-card');
const toggle = document.getElementById('billingToggle');
const monthlyBtn = document.getElementById('monthlyBtn');
const yearlyBtn = document.getElementById('yearlyBtn');
let isYearly = false;
// Intersection Observer for scroll reveal
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe all cards
cards.forEach(card => observer.observe(card));
// Price update function
function updatePrices() {
cards.forEach(card => {
const priceEl = card.querySelector('.price');
const monthlyPrice = card.dataset.monthly;
const yearlyPrice = card.dataset.yearly;
const targetPrice = isYearly ? yearlyPrice : monthlyPrice;
// Animate price change
priceEl.style.transform = 'translateY(-10px)';
priceEl.style.opacity = '0';
setTimeout(() => {
priceEl.textContent = targetPrice;
priceEl.style.transform = 'translateY(0)';
priceEl.style.opacity = '1';
}, 150);
});
}
// Toggle billing period
function setBillingPeriod(yearly) {
isYearly = yearly;
toggle.classList.toggle('yearly', yearly);
toggle.setAttribute('aria-checked', yearly);
monthlyBtn.classList.toggle('active', !yearly);
yearlyBtn.classList.toggle('active', yearly);
updatePrices();
}
// Event listeners
toggle.addEventListener('click', () => setBillingPeriod(!isYearly));
toggle.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
setBillingPeriod(!isYearly);
}
});
monthlyBtn.addEventListener('click', () => setBillingPeriod(false));
yearlyBtn.addEventListener('click', () => setBillingPeriod(true));
// Add transition styles for price animation
document.querySelectorAll('.price').forEach(el => {
el.style.transition = 'transform 0.15s ease, opacity 0.15s ease';
});
// Respect reduced motion preference
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
if (prefersReducedMotion.matches) {
cards.forEach(card => card.classList.add('visible'));
}
</script>
</body>
</html>
功能亮点
-
响应式布局:CSS Grid 实现,在移动端单列、平板双列、桌面三列自适应
-
交互效果:
- 卡片悬停时上浮 + 发光边框效果
- 月付/年付切换,价格平滑过渡动画
- 自定义工具提示,悬停时优雅展示详情
-
视觉设计:
- 深色科技风主题,配合电光青强调色
- 网格背景纹理 + 模糊光晕装饰
- "最受欢迎"标签突出中间卡片
-
无障碍支持:
- 语义化 HTML 结构
- 键盘可操作的切换开关
prefers-reduced-motion 减少动画支持