示例工程 52-browser-compat
52-browser-compat/demo-01-supports/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: 0 0 16px; color: #64748b; font-size: 14px; }
.grid {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.item {
flex: 1 1 140px;
padding: 14px;
border: 1px solid #cbd5e1;
border-radius: 8px;
background: #dbeafe;
color: #1e3a8a;
font-size: 14px;
}
@supports (display: grid) {
.grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
.note {
display: none;
margin-top: 10px;
font-size: 12px;
}
@supports (display: grid) {
.note { display: block; }
}
.color {
margin-top: 16px;
padding: 14px;
border-radius: 8px;
background: #2563eb;
background: oklch(0.62 0.15 262);
color: #ffffff;
font-size: 14px;
}
.var {
margin-top: 8px;
padding: 14px;
border-radius: 8px;
background: var(--warn-soft, #fef3c7);
color: var(--missing, #b45309);
font-size: 14px;
}
@supports selector(:has(*)) {
.grid:has(.item:nth-child(3)) .item:first-child {
outline: 2px solid #2563eb;
}
}