css实现checkbox美化开关效果代码
代码语言:html
所属分类:表单美化
代码描述:css实现checkbox美化开关效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Oswald:700'> <style> body { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; background-color: #CCCCCC; } body span.switcher { position: relative; width: 200px; height: 50px; border-radius: 25px; margin: 20px 0; } body span.switcher input { -webkit-appearance: none; -moz-appearance: none; appearance: none; position: relative; width: 200px; height: 50px; border-radius: 25px; background-color: #1E1E1E; outline: none; font-family: "Oswald", sans-serif; } body span.switcher input:before, body span.switcher input:after { z-index: 2; position: absolute; top: 50%; transform: translateY(-50%); color: #FFFFFF; } body span.switcher input:before { content: "ON"; left: 20px; } body span.switcher input:after { content: "OFF"; right: 20px; } body span.switcher label { z-index: 1; position: absolute; top: 10px; bottom: 10px; border-radius: 20px; } body span.switcher.switcher-1 input { transition: 0.25s -0.1s; } body span.switcher.switcher-1 input:checked { background-color: #FFFFFF; } body span.switcher.switcher-1 input:checked:before { color: #FFFFFF; transition: color 0.5s 0.2s; } body span.switcher.switcher-1 input:checked:after { color: #CCCCCC; transition: color 0.5s; } body span.switcher.switcher-1 input:checked + label { left: 10px; right: 100px; background: #1E1E1E; transition: left 0.5s, right 0.4s 0.2s; } body span.switcher.switcher-1 input:not(:checked) { background: #1E1E1E; transition: background 0.5s -0.1s; } body span.switcher.switcher-1 input:not(:checked):before { color: #CCCCCC; transition: color 0.5s; } body span.........完整代码请登录后点击上方下载按钮下载查看
网友评论0