示例工程 05-colors-units-values
05-colors-units-values/app/style.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
*,
*::before,
*::after {
box-sizing: border-box;
}
body,
h1,
h2,
p {
margin: 0;
}
body {
min-height: 100vh;
background: #f8fafc;
color: #0f172a;
font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
line-height: 1.75;
font-size: 16px;
}
.site-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 16px 24px;
border-bottom: 1px solid #e2e8f0;
background: #ffffff;
}
.brand {
font-size: 13px;
font-weight: 700;
letter-spacing: 0.16em;
}
.site-header nav {
display: flex;
gap: 16px;
}
.site-header nav a {
color: #64748b;
font-size: 0.8125rem;
text-decoration: none;
}
.site-header nav a:hover,
.site-header nav a:focus-visible {
color: #2563eb;
}
.page {
width: min(100% - 2.5rem, 860px);
margin: 0 auto;
padding: 2.5rem 0 4rem;
}
.eyebrow {
color: #64748b;
font-size: 0.6875rem;
letter-spacing: 0.18em;
}
h1 {
margin: 0.375rem 0 0.625rem;
font-size: clamp(1.875rem, 5vw, 2.75rem);
line-height: 1.12;
letter-spacing: -0.03em;
}
.lead {
color: #334155;
font-size: 1rem;
}
.panel {
margin-top: 1.125rem;
padding: 1.5rem;
border: 1px solid #e2e8f0;
border-radius: 1rem;
background: #ffffff;
}
h2 {
font-size: 1.1875rem;
}
.panel p {
margin-top: 0.5rem;
color: #334155;
font-size: 0.875rem;
}
.hint {
color: #64748b;
font-size: 0.75rem;
}
.swatches {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 0.5rem;
margin-top: 0.875rem;
}
.swatch {
display: grid;
place-items: end start;
min-height: 5.5rem;
padding: 0.5rem;
border-radius: 0.625rem;
color: #ffffff;
font-size: 0.625rem;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.swatch.hex { background: #2563eb; }
.swatch.rgb { background: rgb(37 99 235); }
.swatch.hsl { background: hsl(221 83% 53%); }
.swatch.oklch { background: oklch(54% 0.22 262); }
.alpha-row {
display: flex;
gap: 0.5rem;
margin-top: 0.75rem;
padding: 0.5rem;
border-radius: 0.625rem;
background: repeating-linear-gradient(45deg, #e2e8f0 0 0.375rem, #f8fafc 0.375rem 0.75rem);
}
.alpha,
.alpha-strong {
display: inline-block;
padding: 0.25rem 0.5rem;
border-radius: 0.375rem;
color: #0f172a;
font-size: 0.6875rem;
}
.alpha { background: rgb(37 99 235 / 50%); }
.alpha-strong { background: rgb(37 99 235 / 80%); color: #ffffff; }
.units {
margin-top: 0.75rem;
padding: 0.75rem;
border: 1px dashed #cbd5e1;
border-radius: 0.625rem;
}
.units p {
margin: 0.25rem 0;
color: #0f172a;
}
.u-px { font-size: 16px; }
.u-rem { font-size: 1rem; }
.u-em { font-size: 1.25em; }
.u-percent {
width: 50%;
margin-top: 0.5rem;
padding: 0.375rem 0.5rem;
border-radius: 0.375rem;
background: #eff6ff;
color: #1e40af;
font-size: 0.75rem;
}
.fluid-box {
margin-top: 0.875rem;
width: min(100% - 2rem, 680px);
padding: 1rem;
border-radius: 0.75rem;
background: #0f172a;
color: #e2e8f0;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.6875rem;
}
.fluid-note {
font-size: 0.75rem;
}
.contrast .ok {
color: #0f172a;
}
.contrast .low {
color: #cbd5e1;
}
.site-footer {
padding: 1.25rem 1.5rem 2.25rem;
color: #64748b;
font-size: 0.75rem;
text-align: center;
}
@media (max-width: 640px) {
.site-header {
align-items: flex-start;
flex-direction: column;
padding: 0.875rem 1.125rem;
}
.page {
width: min(100% - 1.75rem, 860px);
padding: 1.75rem 0 3rem;
}
.panel {
padding: 1.125rem;
}
.swatches {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}