纯css实现动态背景的checkbox选择框
代码语言:html
所属分类:表单美化
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> .plane-switch { --dot: #fff; --street: #6B6D76; --street-line: #A8AAB4; --street-line-mid: #C0C2C8; --sky-1: #60A7FA; --sky-2: #2F8EFC; --light-1: rgba(255, 233, 0, 1); --light-2: rgba(255, 233, 0, .3); cursor: pointer; -webkit-tap-highlight-color: transparent; } .plane-switch input { display: none; } .plane-switch input + div { -webkit-mask-image: -webkit-radial-gradient(white, black); position: relative; overflow: hidden; width: 50px; height: 25px; padding: 1px; border-radius: 13px; background: linear-gradient(90deg, var(--street) 0%, var(--street) 25%, var(--sky-1) 75%, var(--sky-2) 100%) left var(--p, 0%) top 0; background-position-x: var(--p,0%); background-size: 400% auto; transition: background-position .6s; } .plane-switch input + div:before, .plane-switch input + div:after { content: ''; display: block; position: absolute; -webkit-transform: translateX(var(--s,0)); transform: translateX(var(--s,0)); transition: -webkit-transform .3s; transition: transform .3s; transition: transform .3s, -webkit-transform .3s; } .plane-switch input + div:before { width: 42px; right: 2px; top: 4px; height: 1px; background: var(--street-line); box-shadow: 0 16px 0 0 var(--street-line); } .plane-switch input + div:after { width: 2px; height: 2px; border-radius: 50%; left: 23px; top: 1px; -webkit-animation: lights 2s linear infinite; animation: lights 2s linear infinite; box-shadow: inset 0 0 0 2px var(--light-1), 0 21px 0 var(--light-1), 8px 0 0 var(--light-2), 8px 21px 0 var(--light-2), 16px 0 0 var(--light-2), 16px 21px 0 var(--light-2); } .plane-switch input + div span { display: block; position: absolute; } .plane-switch input + div span.street-middle { top: 12px; lef.........完整代码请登录后点击上方下载按钮下载查看
网友评论0