css中if实现主题色切换效果代码
代码语言:html
所属分类:布局界面
代码描述:css中if实现主题色切换效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
:root {
--text: if(
style(--theme: light): black; style(--theme: dark): white;
style(--theme: custom): rebeccapurple;
);
--background: if(
style(--theme: light): white; style(--theme: dark): black;
style(--theme: custom): #aca;
);
}
:root:has(#theme > [value="light"]:checked) {
--theme: light;
}
:root:has(#theme > [value="dark"]:checked) {
--theme: dark;
}
:root:has(#theme > [value="custom"]:checked) {
--theme: custom;
}
body {
color: var(--text);
background-.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0