css实现accent-color显示两种不同风格的input效果代码

代码语言:html

所属分类:表单美化

代码描述:css实现accent-color显示两种不同风格的input效果代码

代码标签: 显示 两种 不同 风格 input 效果

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">



    <style>
        @property --hue {
          initial-value: 0;
          syntax: '<number>';
          inherits: false;
        }
        
        .animated .accented {
          -webkit-animation: rainbow calc(var(--speed, 1) * 1s) infinite linear;
                  animation: rainbow calc(var(--speed, 1) * 1s) infinite linear;
          -webkit-animation-play-state: var(--animated, paused);
                  animation-play-state: var(--animated, paused);
        }
        
        @-webkit-keyframes rainbow {
          0% {
            --hue: 0;
          }
          100% {
            --hue: 360;
          }
        }
        
        @keyframes rainbow {
          0% {
            --hue: 0;
          }
          100% {
            --hue: 360;
          }
        }
        
        .animated .accented {
          accent-color: hsl(var(--hue) calc(var(--saturation-light, 80) * 1%) calc(var(--lightness-light, 30) * 1%));
        }
        
        .animated [color-scheme="dark"] .accented {
          accent-color: hsl(var(--hue) calc(var(--saturation-dark, 80) * 1%) calc(var(--lightness-dark, 80) * 1%));
        }
        
        .accented {
          accent-color: hsl(var(--huey-light) calc(var(--saturation-light, 80) * 1%) calc(var(--lightness-light, 30) * 1%));
        }
        
        [color-scheme="dark"] .accented {
          accent-color: hsl(var(--huey-dark) calc(var(--saturation-dark, 80) * 1%) calc(var(--lightness-dark, 80) * 1%));
        }
        
        fieldset input {
          --size: 2rem;
          block-size: var(--size);
          inline-size: var(--size);
        }
        
        label {
          display: flex;
          align-items: center;
          justify-content: flex-end;
          gap: 1rem;
        }
        
        [color-scheme="light"] {
          color-scheme: light;
          background: hsl(0, 100%, 100%);
        }
        
        [color-scheme="dark"] {
          color-scheme: dark;
        }
        
        fieldset {
          border: 1px solid hsl(0 0% 50%);
          border-radius: 1rem;
          padding: 1rem;
          display: flex;
          flex-direction: column;
          gap: 1rem;
        }
        
        fieldset[color-scheme="dark"] {
          background: Canvas;
          color: white;
        }
        
        * {
          box-sizing: border-box;
          margin: 0;
        }
        
        html {
          block-size: 100%;
        }
        
        body {
          min-block-size: 100%;
          font-family: system-ui, sans-serif;
          background: hsl(210, 34%, 95%);
          display: grid;
          place-content: center;
          gap: 2rem;
        }
        
        section {
          display: grid;
          gap: 2em;
        }
        
        @media (min-width: 480px) {
          body {
            grid-auto-flow: column;
          }
        }
        
        [type="range"] {
          min-width: 100px;
        }
    </style>

</head>

<body>
    <section>
    .........完整代码请登录后点击上方下载按钮下载查看

网友评论0