示例工程 45-modern-selectors
45-modern-selectors/demo-02-popover/style.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
body {
margin: 0;
padding: 32px;
background: #f8fafc;
color: #0f172a;
font-family: system-ui, sans-serif;
line-height: 1.7;
}
h1 { margin: 0 0 4px; font-size: 26px; }
p { margin: 8px 0 0; color: #64748b; font-size: 14px; }
code { font-family: ui-monospace, monospace; }
.btn {
min-height: 44px;
margin-top: 20px;
padding: 0 18px;
border: 1px solid #2563eb;
border-radius: 8px;
background: #2563eb;
color: #ffffff;
font: inherit;
font-size: 14px;
cursor: pointer;
}
.btn:focus-visible {
outline: 2px solid #1d4ed8;
outline-offset: 2px;
}
#pop {
position: fixed;
inset: 96px auto auto 32px;
width: min(280px, calc(100vw - 32px));
padding: 14px;
border: 1px solid #e2e8f0;
border-radius: 10px;
background: #ffffff;
box-shadow: 0 12px 32px rgb(15 23 42 / 18%);
opacity: 0;
transform: translateY(-6px);
transition:
opacity 160ms ease,
transform 160ms ease,
display 160ms allow-discrete,
overlay 160ms allow-discrete;
}
#pop:popover-open {
opacity: 1;
transform: translateY(0);
}
@starting-style {
#pop:popover-open {
opacity: 0;
transform: translateY(-6px);
}
}
#pop strong { font-size: 14px; }
#pop p { margin-top: 4px; font-size: 12px; }
details {
max-width: 360px;
margin-top: 24px;
font-size: 14px;
}
summary { cursor: pointer; }
summary:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
details p { font-size: 13px; }