css实现三组胶囊开关打开切换效果代码

代码语言:html

所属分类:表单美化

代码描述:css实现三组胶囊开关打开切换效果代码

代码标签: css 胶囊 开关

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

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

<head>
    <meta charset="UTF-8">
    <style>
        html, body {
      height: 100%;
    }
    
    body {
      background: linear-gradient(#f7f7f7, #e0e0e0);
      margin: 0;
    }
    
    .wrap {
      position: relative;
      width: 33.33%;
      margin: -72px 0;
      top: 50%;
      float: left;
    }
    
    label {
      margin: 1.5em auto;
    }
    
    input {
      position: absolute;
      left: -9999px;
    }
    
    .slider-v1 {
      position: relative;
      display: block;
      width: 5.5em;
      height: 3em;
      cursor: pointer;
      border-radius: 1.5em;
      transition: 350ms;
      background: linear-gradient(rgba(0, 0, 0, 0.07), rgba(255, 255, 255, 0)), #ddd;
      box-shadow: 0 0.07em 0.1em -0.1em rgba(0, 0, 0, 0.4) inset, 0 0.05em 0.08em -0.01em rgba(255, 255, 255, 0.7);
    }
    
    .slider-v1::before {
      position: absolute;
      content: '';
      width: 2em;
      height: 2em;
      top: 0.5em;
      left: 0.5em;
      border-radius: 50%;
      transition: 250ms ease-in-out;
      background: linear-gradient(#f5f5f5 10%, #eeeeee);
      box-shadow: 0 0.1em 0.15em -0.05em rgba(255, 255, 255, 0.9) inset, 0 0.5em 0.3em -0.1em rgba(0, 0, 0, 0.25);
    }
    
    .slider-v1::after {
      position: absolute;
      content: '';
      width: 1em;
      height: 1em;
      top: 1em;
      left: 6em;
      border-radius: 50%;
      transition: 250ms ease-in;
      background: linear-gradient(rgba(0, 0, 0, 0.07), rgba(255, 255, 255, 0.1)), #ddd;
      box-shadow: 0 0.08em 0.15em -0.1em rgba(0, 0, 0, 0.5) inset, 0 0.05em 0.08em -0.01em rgba(255, 255, 255, 0.7), -7.25em 0 0 -0.25em rgba(0, 0, 0, 0.3);
    }
    
    input:checked + .slider-v1::after {
      background: linear-gradient(rgba(0, 0, 0, 0.07), rgba(255, 255, 255, 0.1)), #4c6;
      box-shadow: 0 0.08em 0.15em -0.1em rgba(0, 0, 0, 0.5) inset, 0 0.05em 0.08em -0.01em rgba(255, 255, 255, 0.7), -7.25em 0 0 -0.25em rgba(0, 0, 0, 0.12);
    }
    
    input:checked + .slider-v1::before {
      left: 3em;
    }
    
    .slider-v2 {
      position: relative;
      display: block;
      width: 5.5em;
      height: 3em;
      cursor: pointer;
      border-radius: 1.5em;
      transition: 350ms;
      background: linear-gradient(rgba(0, 0, 0, 0.07), rgba(255, 255, 255, 0)), #ddd;
      box-shadow: 0 0.07em 0.1em -0.1em rgba(0, 0, 0, 0.4) inset, 0 0.05em 0.08em -0.01em rgba(255, 255, 255, 0.7);
    }
    
    .slider-v2::after {
      position: absolute;
      content: '';
      width: 2em;
      height: 2em;
      top: 0.5em;
      left: 0.5em;
      border-radius: 50%;
      transition: 250ms ease-in-out;
      background: linear-gradient(#f5f5f5 10%, #eeeeee);
      box-shadow: 0 0.1em 0.15em -0.05em rgba(255,.........完整代码请登录后点击上方下载按钮下载查看

网友评论0