css实现卷纸checkbox铺开开关效果代码
代码语言:html
所属分类:布局界面
代码描述:css实现卷纸checkbox铺开开关效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --sz: 10vmin; --tr: all 0.5s ease 0s; } * { box-sizing: border-box; transition: var(--tr); } body { margin: 0; padding: 0; width: 100vw; height: 100vh; overflow: hidden; display: flex; align-items: center; justify-content: center; background: linear-gradient(205deg, #5c6279, #2d303b); } .toggle { position: relative; width: calc(var(--sz)* 4); height: calc(var(--sz)* 2); display: flex; align-items: center; justify-content: center; filter: drop-shadow(-2px 2px 4px #0003); } .toggle:before { content: ""; position: absolute; width: 2vmin; top: 4vmin; height: calc(100% - 4vmin); background: #fff; left: -1.9vmin; clip-path: polygon(0% 0%, 18% 8%, 2% 39%, 21% 80%, 2% 90%, 15% 105%, 100% 100%, 100% 0%); } .toggle:after { content: ""; position: absolute; width: 0.2vmin; top: 4vmin; left: 12.25vmin; height: calc(100% - 4vmin); background: repeating-linear-gradient(180deg, #ccc6 0 0.8vmin, #fff calc(0.8vmin + 1px) calc(0.8vmin + 2px)); } input { display: none; } label[for=btn] { position: absolute; width: calc(var(--sz)* 4); height: calc(var(--sz)* 2); background: linear-gradient(90deg, #fff 30%, #fff0 30%); background-size: 100% calc(100% - 4vmin); background-repeat: no-repeat; background-position: 0 4vmin; transition: background-size 0.5s ease 0s; } #btn:checked + label { background-size: 260% calc(100% - 4vmin); } label[for=btn]:before, label[for=btn]:after { content: "ON"; position: absolute; width: 50%; text-align: center; height: 100%; line-height: 23vmin; font-size: 8vmin; font-family: Arial, Helvetica, serif; transform: scaleY(1.1); padding: 0 2vmin; color: #9acd32; text-shadow: 0 1px 2px #0008, 0 -2px 1px #eee; } label[for=btn]:after { content: "OFF"; right: 0.5vmin; pad.........完整代码请登录后点击上方下载按钮下载查看
网友评论0