首页 / CSS3 / Css3制作动态开关的效果的实现步骤
Css3制作动态开关的效果的实现步骤
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Css3制作动态开关的效果的实现步骤,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2582字,纯文字阅读大概需要4分钟。
内容图文
CSS3制作动态左右开关,动态开关按钮是一款非常酷的CSS3的开关按钮,点击按钮可以左右滑动,就像开关打开闭合一样的效果,通过本篇文章给大家介绍纯CSS3代码实现滑动开关效果,需要的朋友可以参考下<!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> body{ background: black; } * { margin: 0; padding: 0; } body { padding: 26%; } .button { display: inline-block; position: relative; height: 40px; -webkit-user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer; background-color: #eee; border-radius: 30px; } input { opacity: 0; position: absolute; top: 0; left: 0; } .button:before { content: ""; display: inline-block; width: 80px; height: 42px; background-color: #fff; border-radius: 42px; box-sizing: border-box; border: 2px solid #eee; transition: all 0.2s linear; } .button:after { position: absolute; left: 2px; top: 2px; content: ""; display: inline-block; width: 38px; height: 38px; background-color: #fff; border-radius: 40px; transition: all 0.2s linear; box-shadow: 0px 1px 3px #bbb; } input:checked ~ .button:before { background-color: red; border: 1px solid red; } input:checked ~ .button:after { left: 40px; } </style> </head> <body> <input type="checkbox" id="swtich"> <label for="swtich"></label> </body> </html><!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> body{ background: black; } * { margin: 0; padding: 0; } body { padding: 26%; } .button { display: inline-block; position: relative; height: 40px; -webkit-user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer; background-color: #eee; border-radius: 30px; } input { opacity: 0; position: absolute; top: 0; left: 0; } .button:before { content: ""; display: inline-block; width: 80px; height: 42px; background-color: #fff; border-radius: 42px; box-sizing: border-box; border: 2px solid #eee; transition: all 0.2s linear; } .button:after { position: absolute; left: 2px; top: 2px; content: ""; display: inline-block; width: 38px; height: 38px; background-color: #fff; border-radius: 40px; transition: all 0.2s linear; box-shadow: 0px 1px 3px #bbb; } input:checked ~ .button:before { background-color: red; border: 1px solid red; } input:checked ~ .button:after { left: 40px; } </style> </head> <body> <input type="checkbox" id="swtich"> <label for="swtich"></label> </body> </html>
相信看了这些案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!
相关阅读:
CSS3关于translate属性的详细介绍
CSS3关于background-size属性的详细介绍
CSS3函数rotate()怎么使用
以上就是Css3制作动态开关的效果的实现步骤的详细内容,更多请关注Gxl网其它相关文章!
内容总结
以上是互联网集市为您收集整理的Css3制作动态开关的效果的实现步骤全部内容,希望文章能够帮你解决Css3制作动态开关的效果的实现步骤所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。