示例工程 29-cards-navigation
29-cards-navigation/demo-02-nav/style.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
:root {
--border: #e2e8f0;
--surface: #ffffff;
--text: #0f172a;
--muted: #64748b;
--primary: #2563eb;
--focus: #2563eb;
}
body {
margin: 0;
background: #f8fafc;
color: var(--text);
font-family: system-ui, sans-serif;
line-height: 1.7;
}
.bar {
position: sticky;
top: 0;
z-index: 10;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 12px 20px;
border-bottom: 1px solid var(--border);
background: var(--surface);
}
.links {
display: flex;
gap: 14px;
}
.links a {
color: var(--muted);
font-size: 13px;
text-decoration: none;
}
.links a:hover,
.links a:focus-visible {
color: var(--primary);
}
.menu {
display: none;
width: 44px;
height: 44px;
border: 1px solid var(--border);
border-radius: 8px;
background: var(--surface);
font-size: 18px;
cursor: pointer;
}
main {
max-width: 720px;
margin: 0 auto;
padding: 24px 20px 60vh;
}
section {
padding: 40px 0;
border-bottom: 1px solid var(--border);
scroll-margin-top: 76px;
}
h1, h2 { margin: 0 0 8px; }
.drawer {
position: fixed;
inset: 0 0 0 auto;
width: min(78vw, 300px);
height: 100dvh;
margin: 0;
padding: 16px;
border: 0;
border-left: 1px solid var(--border);
background: var(--surface);
}
.drawer::backdrop {
background: rgb(15 23 42 / 45%);
}
.close {
width: 44px;
height: 44px;
border: 0;
border-radius: 8px;
background: transparent;
font-size: 20px;
cursor: pointer;
}
.drawer nav {
display: grid;
gap: 4px;
margin-top: 8px;
}
.drawer nav a {
display: flex;
align-items: center;
min-height: 44px;
padding: 0 8px;
border-radius: 8px;
color: var(--text);
text-decoration: none;
}
.drawer nav a:hover,
.drawer nav a:focus-visible {
background: #f8fafc;
color: var(--primary);
}
.menu:focus-visible,
.close:focus-visible,
.drawer nav a:focus-visible,
.links a:focus-visible {
outline: 2px solid var(--focus);
outline-offset: 2px;
}
@media (max-width: 640px) {
.links { display: none; }
.menu { display: block; }
}