红绿转变药丸checkbox选择效果代码

代码语言:html

所属分类:表单美化

代码描述:红绿转变药丸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(20px + (30 - 20) * (100vw - 320px) / (1280 - 320));
}

body, input {
  font: 1em/1.5 sans-serif;
}

body {
  background: #e3e4e8;
  display: grid;
  height: 100vh;
  place-items: center;
}

.pill {
  cursor: pointer;
  width: 7.5em;
  height: 3.75em;
}
.pill, .pill input[type=checkbox], .pill input[type=checkbox]:before, .pill input[type=checkbox]:after {
  display: block;
}
.pill, .pill input[type=checkbox] {
  -webkit-tap-highlight-color: transparent;
}
.pill input[type=checkbox] {
  animation-name: pillOff;
  background-attachment: fixed;
  background-image: linear-gradient(90deg, #da0b0b 50%, #09aa09 50%);
  border-radius: 1.875em;
  cursor: pointer;
  position: relative;
  width: 3.75em;
  height: inherit;
  transition: box-shadow 0.15s linear;
  -webkit-appearance: none;
  appearance: none;
}
.pill input[type=checkbox], .pill input[type=checkbox]:after {
  animation-duration: 0.6s;
  animation-timing-function: ease-in-out;
  animation-fill-mode: forwards;
}
.pill input[type=checkbox]:before, .pill input[type=checkbox]:after {
  content: "";
  position: absolute;
}
.pill input[type=checkbox]:before {
  background-image: radial-gradient(0.9375em 0.825em at 1.875em 1.125em, rgba(255, 255, 255, 0.27) 40%, rgba(255, 255, 255, 0) 50%);
  border-radius: inherit;
  box-shadow: 0.05em -0.025em 0.25em 0.05em rgba(255, 255, 255, 0.4) inset, 0.125em -0.125em 0.15em 0.25em rgba(255, 255, 255, 0.07) inset, 0 -0.75em 0.175em 0 rgba(0, 0, 0, 0.07) inset, 0 -0.65em 0.05em 0.45em rgba(255, 255, 255, 0.07) inset, 0 -0.375em 0.05em 0.45em rgba(255, 255, 255, 0.1) inset, 0 0.75em 0.75em 0 rgba(0, 0, 0, 0.27);
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.pill input[type=checkbox]:after {
  animation-name: pillOffAfter;
  background-color: rgba(255, 255, 255, 0.27);
  border-radius: 0.2em;
  box-shadow: 0 0 0.1em 0.1em rgba(255, 255, 255, 0.27);
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0