css的color-scheme实现页面元素亮色与暗色切换代码

代码语言:html

所属分类:布局界面

代码描述:css的color-scheme实现页面元素亮色与暗色切换代码

代码标签: css color-scheme 页面 元素 亮色 暗色

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  <meta name="viewport" content="width=device-width, initial-scale=1">
  
  
  
<style>
.dark {
  color-scheme: dark;
}

.light {
  color-scheme: light;
}

section {
  background: light-dark(#ddd, #222);
  color: light-dark(#222, #ddd);
}











@layer support {
  * {
    box-sizing: border-box;
    margin: 0;
  }

  html {
    block-size: 100%;
  }

  body {
    min-block-size: 100%;
    font-family: system-ui, sans-serif;
    display: grid;
    
    @media (orientation: landscape) {
      grid-auto-flow: column;
    }
  }
  
  section {
    d.........完整代码请登录后点击上方下载按钮下载查看

网友评论0