div+css实现立体圆柱滚动开关效果代码
代码语言:html
所属分类:布局界面
代码描述:div+css实现立体圆柱滚动开关效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> * { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --hue: 223; --bg: hsl(var(--hue),10%,90%); --fg: hsl(var(--hue),10%,10%); --trans-dur: 0.4s; font-size: calc(40px + (60 - 40) * (100vw - 320px) / (2560 - 320)); } body, input { color: var(--fg); font: 1em/1.5 Helvetica, sans-serif; } body { background-color: var(--bg); display: flex; height: 100vh; transition: background-color var(--trans-dur), color var(--trans-dur); } .switch, .switch__input, .switch__handle-sides, .switch__handle-side, .switch__handle-labels, .switch__handle-label, .switch__handle-texture { display: block; } .switch, .switch__input { cursor: pointer; -webkit-tap-highlight-color: transparent; } .switch { margin: auto; position: relative; width: 3em; height: 3em; } .switch__input { background-color: hsl(var(--hue),10%,95%); border-radius: 0.25em; box-shadow: 0.125em 0.125em 0.125em hsl(0,0%,100%) inset, -0.125em -0.125em 0.125em hsl(var(--hue),10%,85%) inset, 0.125em 0.125em 0.375em hsl(var(--hue),10%,70%); outline: transparent; position: relative; width: 100%; height: 100%; transition: background-color var(--trans-dur), box-shadow var(--trans-dur); -webkit-appearance: none; appearance: none; } .switch__input:before { border-radius: inherit; box-shadow: 0 0 0 max(0.125em,1px) hsla(var(--hue),90%,50%,0); content: ""; display: block; position: absolute; inset: 0; transition: box-shadow 0.15s linear; } .switch__input:focus-visible:before { box-shadow: 0 0 0 max(0.125em,1px) hsla(var(--hue),90%,50%,1); } .switch__handle, .switch__handle-sides, .switch__handle-side, .switch__handle-labels, .switch__handle-label { position: absolute; } .switch__handle, .switch__handle-label { transition: transform var(--trans-dur) cubic-bezier(0.65,0,0.36,1.6); } .switch__handle, .switch__handle-sides, .switch__handle-texture { border-radius: 0.125em; } .switch__handle { box-shadow: 0.25em 0.25em 0.25em hsla(var(--hue),10%,10%,0.4); top: 10%; left: 10%; width: 40%; height: 80%; } .switch__handle-sides, .switch__handle-labels, .switch__handle-texture { width: 100%; height: 100%; } .switch__handle-sides, .switch__handle-side { background-color: hsl(var(--hue),10%,85%); transition: background-color var(--trans-dur), transform var(--trans-dur) cubic-bezier(0.65,0,0.36,1.6); } .switch__handle-sides { --side-on: hsl(123,90%,40%); background-image: linear-gradient(90deg,transparent 50%,var(--side-on) 50%); overflow: hidden; } .switch__handle-side { background-image: linear-gradient(90deg,var(--side-on) 50%,transparent 50%); transform: translateX(-50%); width: 200%; height: 100%; } .switch__handle-labels { transform-style: preserve-3d; -webkit-user.........完整代码请登录后点击上方下载按钮下载查看
网友评论0