原生 CSS 变量与多主题深浅配色无缝切换架构
一、CSS 变量分层设计
:root {
--bg-color: #fcfcfc;
--text-main: #111827;
}
[data-theme="dark"] {
--bg-color: #0d1117;
--text-main: #f0f6fc;
}
:root {
--bg-color: #fcfcfc;
--text-main: #111827;
}
[data-theme="dark"] {
--bg-color: #0d1117;
--text-main: #f0f6fc;
}