css实现齿轮checkbox胶囊选择效果代码

代码语言:html

所属分类:表单美化

代码描述:css实现齿轮checkbox胶囊选择效果代码

代码标签: checkbox 胶囊 选择 效果

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">



    <style>
        * {
          border: 0;
          box-sizing: border-box;
          margin: 0;
          padding: 0;
        }
        
        :root {
          font-size: calc(24px + (32 - 24) * (100vw - 320px) / (1280 - 320));
        }
        
        body, input {
          font: 1em/1.5 sans-serif;
        }
        
        body {
          background: #abafba;
          height: 100vh;
          display: grid;
          place-items: center;
        }
        
        .saw-switch {
          border-radius: 2.5em;
          width: 8em;
          height: 5em;
        }
        .saw-switch__inner, .saw-switch__blade, .saw-switch__particle {
          pointer-events: none;
        }
        .saw-switch__inner, .saw-switch__input {
          position: relative;
        }
        .saw-switch__inner {
          display: block;
          margin: 1em;
          width: calc(100% - 2em);
          height: calc(100% - 2em);
          -webkit-tap-highlight-color: transparent;
        }
        .saw-switch__input {
          background-color: #f42f25;
          border-radius: 1.5em;
          box-shadow: 0 0 0 0.2em inset;
          color: #e3e4e8;
          width: 100%;
          height: 100%;
          transition: background-color 0.25s ease-in-out;
          -webkit-appearance: none;
          appearance: none;
        }
        .saw-switch__input:before {
          border-radius: 50%;
          content: "";
          display: block;
          top: 0.5em;
          left: 0.5em;
          width: 2em;
          height: 2em;
          transition: transform 0.25s ease-in-out;
        }
        .saw-switch__input:checked {
          background-color: #0bda16;
        }
        .saw-switch__input:checked:before {
          transform: translateX(3em);
        }
        .saw-switch__input:be.........完整代码请登录后点击上方下载按钮下载查看

网友评论0