示例工程 44-color-functions
44-color-functions/demo-02-mix/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: 16px 0 8px; color: #64748b; font-size: 14px; }
:root { --brand: #2563eb; }
.row {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.box {
display: flex;
align-items: flex-end;
width: 150px;
height: 100px;
padding: 8px;
border-radius: 10px;
font-size: 11px;
font-family: ui-monospace, monospace;
}
.srgb {
background: color-mix(in srgb, var(--brand) 50%, white);
color: #0f172a;
}
.oklab {
background: color-mix(in oklab, var(--brand) 50%, white);
color: #0f172a;
}
.rel {
background: oklch(from var(--brand) calc(l + 0.18) calc(c * 0.5) h);
color: #0f172a;
}
.brighter {
background: oklch(from var(--brand) calc(l + 0.12) c h);
color: #0f172a;
}
.muted {
background: oklch(from var(--brand) l calc(c * 0.4) h);
color: #0f172a;
}
.shifted {
background: oklch(from var(--brand) l c calc(h + 40));
color: #ffffff;
}