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:before, .saw-switch__blade {
          background-color: #e3e4e8;
          position: absolute;
        }
        .saw-switch__blade {
          animation: revolve 99999s linear infinite;
          clip-path: polygon(50% 0, 100% 100%, 0 100%);
          bottom: 50%;
          left: 1em;
          width: 1em;
          height: 1em;
          transform: translate(0em, -1.4em) rotate(0deg);
          transform-origin: 50% 2.4em;
        }
        .saw-switch__input:checked ~ .saw-switch__blade {
          animation-duration: 1.2s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(3) {
          animation-delay: -7142.7857142857s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(3) {
          animation-delay: -0.0857142857s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(4) {
          animation-delay: -14285.5714285714s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(4) {
          animation-delay: -0.1714285714s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(5) {
          animation-delay: -21428.3571428571s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(5) {
          animation-delay: -0.2571428571s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(6) {
          animation-delay: -28571.1428571429s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(6) {
          animation-delay: -0.3428571429s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(7) {
          animation-delay: -35713.9285714286s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(7) {
          animation-delay: -0.4285714286s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(8) {
          animation-delay: -42856.7142857143s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(8) {
          animation-delay: -0.5142857143s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(9) {
          animation-delay: -49999.5s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(9) {
          animation-delay: -0.6s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(10) {
          animation-delay: -57142.2857142857s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(10) {
          animation-delay: -0.6857142857s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(11) {
          animation-delay: -64285.0714285714s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(11) {
          animation-delay: -0.7714285714s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(12) {
          animation-delay: -71427.8571428571s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(12) {
          animation-delay: -0.8571428571s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(13) {
          animation-delay: -78570.6428571429s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(13) {
          animation-delay: -0.9428571429s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(14) {
          animation-delay: -85713.4285714286s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(14) {
          animation-delay: -1.0285714286s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(15) {
          animation-delay: -92856.2142857143s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(15) {
          animation-delay: -1.1142857143s;
        }
        .saw-switch__input ~ .saw-switch__blade:nth-child(16) {
          animation-delay: -99999s;
        }
        .saw-switch__input:checked ~ .saw-switch__blade:nth-child(16) {
          animation-delay: -1.2s;
        }
        .saw-switc.........完整代码请登录后点击上方下载按钮下载查看

网友评论0