css实现昼夜切换按钮开关效果代码
代码语言:html
所属分类:表单美化
代码描述:css实现昼夜切换按钮开关效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { /** sunny side **/ --blue-background: #c2e9f6; --blue-border: #72cce3; --blue-color: #96dcee; --yellow-background: #fffaa8; --yellow-border: #f5eb71; /** dark side **/ --indigo-background: #808fc7; --indigo-border: #5d6baa; --indigo-color: #6b7abb; --gray-border: #e8e8ea; --gray-dots: #e8e8ea; /** general **/ --white: #fff; } @keyframes reverse { 0% { left: 104px; width: 82px; } 60% { left: 72px; width: 112px; } 100% { left: 4px; } } @keyframes switch { 0% { left: 4px; } 60% { left: 4px; width: 112px; } 100% { left: 104px; width: 82px; } } body { display: grid; place-items: center; min-height: 100vh; position: relative; padding: 0; margin: 0; } .toggle--checkbox { display: none; } .toggle--label { width: 200px; height: 100px; background: var(--blue-color); border-radius: 100px; border: 5px solid var(--blue-border); display: flex; position: relative; transition: all 350ms ease-in; } .toggle--label:before { animation-name: reverse; animation-duration: 350ms; animation-fill-mode: forwards; transition: all 350ms ease-in; content: ""; width: 82px; height: 82px; border: 5px solid var(--yellow-border); top: 4px; left: 4px; position: absolute; border-radius: 82px; background: var(--yellow-background); } .toggle--label .toggle--label-background { width: 10px; height: 5px; border-radius: 5px; position: relative; background: var(--white); left: 135px; top: 45px; transition: all 150ms ease-in; } .toggle--label .toggle--label-background:before { content: ""; position: absolute; top: -5px; width: 40px; height: 5px; border-radius: 5px; background: var(--white); left: -20px; transition: all 150ms ease-in; } .togg.........完整代码请登录后点击上方下载按钮下载查看
网友评论0