CSS3滑动开关按钮效果
分类:实例代码
CSS3滑动开关按钮效果属于前端实例代码,有关更多实例代码大家可以查看。
分享一段代码实例,它实现了左右滑动的开关按钮效果。
代码实例如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="http://www.pipipi.net/" /> <title>前端教程网</title> <style type="text/css"> input[type="checkbox"]{ display:none; } input + label{ box-shadow:rgb(0,0,0) 0px 0px 0px 1px; width:40px; height:20px; display:inline-block; border-radius:20px; position:relative; background-color:white; overflow:hidden; } input + label:before{ content:''; position:absolute; box-shadow:rgb(0,0,0) 0px 0px 0px 1px; left:0px; width:20px; height:20px; display:inline-block; border-radius:20px; background-color:white; z-index:20; transition:all 0.5s; } input + label:after{ content:''; position:absolute; border-radius:20px; left:-20px; width:40px; height:20px; display:inline-block; background-color:rgb(108, 185, 255); transition:all 0.5s; } input:checked + label:before{ left:20px; } input:checked + label:after{ left:0px; } </style> </head> <body> <input type="checkbox" name="sex" id="male" /> <label for="male"></label> </body> </html>
CSS3滑动开关按钮效果,这样的场景在实际项目中还是用的比较多的,关于CSS3滑动开关按钮效果就介绍到这了。