示例工程 12-stacking-context
12-stacking-context/app/style.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
*,
*::before,
*::after {
box-sizing: border-box;
}
body,
h1,
h2,
h3,
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.7;
}
.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: 13px;
text-decoration: none;
}
.site-header nav a:hover,
.site-header nav a:focus-visible {
color: #2563eb;
}
.page {
width: min(100% - 40px, 900px);
margin: 0 auto;
padding: 32px 0 64px;
}
.cover {
position: relative;
min-height: 420px;
border-radius: 20px;
overflow: hidden;
isolation: isolate;
background: #0f172a;
}
.cover-bg {
position: absolute;
inset: 0;
background:
radial-gradient(circle at 78% 22%, rgb(96 165 250 / 70%) 0 10%, transparent 10.5%),
radial-gradient(circle at 18% 82%, rgb(124 58 237 / 65%) 0 14%, transparent 14.5%),
linear-gradient(135deg, #0f172a, #1e3a8a 55%, #4c1d95);
z-index: -1;
}
.cover-card {
position: absolute;
left: 28px;
bottom: 28px;
max-width: 440px;
padding: 24px;
border: 1px solid rgb(255 255 255 / 22%);
border-radius: 16px;
background: rgb(255 255 255 / 92%);
box-shadow: 0 24px 60px rgb(2 6 23 / 35%);
z-index: 2;
}
.issue {
color: #2563eb;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.18em;
}
.cover-card h1 {
margin-top: 6px;
font-size: clamp(34px, 6vw, 54px);
line-height: 1.05;
letter-spacing: -0.03em;
}
.dek {
margin-top: 8px;
color: #1e293b;
font-size: 15px;
font-weight: 600;
}
.byline {
margin-top: 10px;
color: #64748b;
font-size: 12px;
}
.cover-badge {
position: absolute;
top: 20px;
right: 20px;
padding: 6px 12px;
border-radius: 999px;
background: #f59e0b;
color: #451a03;
font-size: 11px;
font-weight: 700;
z-index: 3;
}
.panel {
margin-top: 18px;
padding: 24px;
border: 1px solid #e2e8f0;
border-radius: 16px;
background: #ffffff;
}
h2 {
font-size: 19px;
}
.panel p {
margin-top: 8px;
color: #334155;
font-size: 14px;
}
.stack-demo {
position: relative;
height: 220px;
margin-top: 14px;
border: 1px dashed #cbd5e1;
border-radius: 10px;
background: #f8fafc;
}
.layer {
position: absolute;
width: 170px;
height: 100px;
padding: 10px;
border-radius: 10px;
color: #ffffff;
font-size: 12px;
font-family: ui-monospace, Menlo, monospace;
}
.layer-a {
top: 30px;
left: 30px;
background: #2563eb;
z-index: 1;
}
.layer-b {
top: 70px;
left: 110px;
background: #7c3aed;
z-index: 3;
}
.layer-c {
top: 110px;
left: 190px;
background: #db2777;
z-index: 2;
}
.note-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
margin-top: 14px;
}
.note {
padding: 16px;
border: 1px solid #e2e8f0;
border-radius: 12px;
background: #f8fafc;
}
.note h3 {
font-size: 14px;
}
.note p {
margin-top: 6px;
color: #64748b;
font-size: 12px;
}
.site-footer {
padding: 20px 24px 36px;
color: #64748b;
font-size: 12px;
text-align: center;
}
@media (max-width: 640px) {
.site-header {
align-items: flex-start;
flex-direction: column;
padding: 14px 18px;
}
.page {
width: min(100% - 28px, 900px);
padding: 20px 0 48px;
}
.cover {
min-height: 380px;
}
.cover-card {
left: 16px;
right: 16px;
bottom: 16px;
padding: 18px;
}
.cover-badge {
top: 14px;
right: 14px;
}
.note-grid {
grid-template-columns: 1fr;
}
.stack-demo {
height: 260px;
}
.layer {
width: 150px;
}
.layer-c {
left: 80px;
}
}