div+css布局实现checkbox立体质感开关效果代码

代码语言:html

所属分类:布局界面

代码描述:div+css布局实现checkbox立体质感开关效果代码

代码标签: div css 布局 checkbox 立体 质感 开关

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

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

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

  
  
  
<style>
body {
  display: grid;
  place-items: center;
  overflow: hidden;
  margin: 0;
  height: 100vh;
  background:
    radial-gradient(at 100% 0, #fffa, #fff0 50%),
    radial-gradient(at 0% 100%, #0002, #0000 50%),
    #c4c1c3;
}

.rebound {
  --color: #c4c1c3;
  --background-off: #767576;
  --background-on: #b3e82a ;
  --time: 0.3s;
  appearance: none;
  position: relative;
/*   width: 2em; */
  width: 11em;
  aspect-ratio: 11 / 3;
  border-radius: 100em;
  background-color: #76757a;
  background-image:
    linear-gradient(#0001, #0000),
    linear-gradient(90deg, var(--background-on) 50%, var(--background-off) 0)
    ;
  box-shadow:
    inset 0 0.05em 0.25em #0008,
    inset 0 0.5em 0.5em #0004,
    0 -0.1em 0.15em 0.075em #0006,
    0 0.1em 0.15em 0.075em #fffc
    ;
  
  &::before {
    content: "";
    top: 0;
    left: 0.5%;
    width: 60%;
    height: 100%;
    position: absolute;
    border-radius: 100em;
    transition: left var(--time) linear;
    padding: 0.625em 1.625em;
    box-sizing: border-box;
    background:
      linear-gradient(90deg, #0004, #0000 45% 75%, #0003) 34% 50% / 4% 40%,
      radial-gradient(farthest-side at 50% 0, #0005 50%, #0000) 34% 72% / 4% 3%,
      radial-gradient(farthest-side at 50% 100%, #fff7 50%, #0000) 34% 28% / 4% 3%,
      
      linear-gradient(90deg, #0004, #0000 45% 75%, #0003) 42% 50% / 4% 40%,
      radial-gradient(farthest-side at 50% 0, #0005 50%, #0000) 42% 72% / 4% 3%,
      radial-gradient(farthest-.........完整代码请登录后点击上方下载按钮下载查看

网友评论0