css实现blob checkbox开关切换效果代码
代码语言:html
所属分类:其他
代码描述:css实现blob checkbox开关切换效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --color-primary: #75d8ee; --color-secondary: #ee75d2; --color-tertiary: #ffd600; --color-quaternary: #9375ee; --color-surface: #0e0331; } .container { filter: url(#blurFilter); width: inherit; height: inherit; border-radius: inherit; display: flex; justify-content: space-between; align-items: center; padding: 0 calc(var(--height) / 4); box-sizing: border-box; position: relative; } .switch { --width: 16vmax; --height: 8vmax; width: var(--width); height: var(--height); border-radius: var(--height); border: 0.5vmax solid color-mix(in srgb, var(--color-secondary), transparent 40%); cursor: pointer; } .switch .thumb { position: absolute; background: var(--color-primary); border-radius: inherit; height: inherit; left: 0; aspect-ratio: 1; -webkit-animation: unchecked 0.65s ease-out forwards; animation: unchecked 0.65s ease-out forwards; } .switch .left, .switch .right { border-radius: inherit; height: calc(var(--height) / 2); aspect-ratio: 1; } .switch .left { background: var(--color-secondary); } .switch .right { background: var(--color-primary); } .switch input { display: none; } .switch input:checked ~ .container .thumb { -webkit-animation: checked 0.65s ease-out forwards; animation: checked 0.65s ease-out forwards; } @-webkit-keyframes checked { from { translate: 0; scale: 1; } 50% { scale: 0.4; background-color: var(--color-secondary); } to { scale: 1; translate: calc(var(--width) - var(--height)); background-color: var(--color-primary); } } @keyframes checked { from { translate: 0; scale: 1; } 50% { scale: 0.4; background-color: var(--color-secondary); } to { scale: 1; translate: calc(var(--width) - var(--height)); background-color: var(--color-primary); } } @-webkit-keyframes unchecked { from { .........完整代码请登录后点击上方下载按钮下载查看
网友评论0