示例工程 22-mobile-first
22-mobile-first/app/style.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
*,
*::before,
*::after {
box-sizing: border-box;
}
body,
h1,
h2,
h3,
p {
margin: 0;
}
body {
background: #f8fafc;
color: #0f172a;
font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
line-height: 1.7;
}
a {
color: inherit;
}
/* 默认:手机。所有布局先按单列写 */
.site-header {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0.75rem;
padding: 0.875rem 1.125rem;
border-bottom: 1px solid #e2e8f0;
background: #ffffff;
}
.brand {
font-size: 0.75rem;
font-weight: 700;
letter-spacing: 0.14em;
text-decoration: none;
}
.nav {
display: flex;
flex-wrap: wrap;
gap: 0.875rem;
width: 100%;
}
.nav a {
color: #64748b;
font-size: 0.8125rem;
text-decoration: none;
}
.nav a:hover,
.nav a:focus-visible {
color: #2563eb;
}
.hero {
padding: 2.5rem 1.125rem 2rem;
}
.eyebrow {
color: #64748b;
font-size: 0.6875rem;
letter-spacing: 0.18em;
}
h1 {
margin: 0.375rem 0 0.625rem;
font-size: clamp(1.75rem, 7vw, 2.75rem);
line-height: 1.12;
}
.lead {
max-width: 48ch;
color: #334155;
font-size: 1rem;
}
.actions {
display: flex;
flex-direction: column;
gap: 0.625rem;
margin-top: 1.25rem;
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 2.75rem;
padding: 0 1rem;
border: 1px solid #cbd5e1;
border-radius: 0.625rem;
background: #ffffff;
color: #0f172a;
font-size: 0.875rem;
text-align: center;
text-decoration: none;
}
.btn.primary {
border-color: #2563eb;
background: #2563eb;
color: #ffffff;
}
.section {
padding: 1.5rem 1.125rem 2.25rem;
}
.section h2 {
font-size: 1.25rem;
}
.features,
.plans {
display: grid;
gap: 0.75rem;
margin-top: 0.875rem;
}
.feature,
.plan {
padding: 1rem;
border: 1px solid #e2e8f0;
border-radius: 0.875rem;
background: #ffffff;
}
.feature h3,
.plan h3 {
font-size: 1rem;
}
.feature p,
.plan p {
margin-top: 0.375rem;
color: #64748b;
font-size: 0.8125rem;
}
.plan {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.price {
color: #0f172a !important;
font-size: 1.625rem;
font-weight: 700;
line-height: 1.2;
}
.plan .btn {
margin-top: 0.5rem;
}
.featured {
border-color: #2563eb;
}
details {
margin-top: 0.75rem;
padding: 0.875rem 1rem;
border: 1px solid #e2e8f0;
border-radius: 0.75rem;
background: #ffffff;
}
summary {
cursor: pointer;
font-size: 0.9375rem;
font-weight: 600;
}
details p {
margin-top: 0.5rem;
color: #64748b;
font-size: 0.8125rem;
}
.site-footer {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 1.5rem 1.125rem 2.5rem;
color: #64748b;
font-size: 0.75rem;
}
/* 第一级增强:平板 */
@media (min-width: 640px) {
.site-header {
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 1rem 1.5rem;
}
.nav {
width: auto;
gap: 1.25rem;
}
.hero {
padding: 3.5rem 1.5rem 2.5rem;
}
.actions {
flex-direction: row;
align-items: center;
}
.actions .btn {
min-width: 9rem;
}
.section {
padding: 2rem 1.5rem 3rem;
}
.features {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.site-footer {
flex-direction: row;
align-items: center;
justify-content: space-between;
}
}
/* 第二级增强:桌面 */
@media (min-width: 900px) {
.hero,
.section {
width: min(100% - 3rem, 960px);
margin: 0 auto;
}
.features {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.plans {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}