[css]switch开关按钮,适用于移动端和IE9火狐谷歌
来源:互联网 发布:http端口号设置 编辑:程序博客网 时间:2024/06/05 18:13
参考移动端的switch按钮的CSS写法,弄了一个在手机和PC上都能用的(ie9以及以上,IE9大致能用,但是过度动画不平滑)。
效果图如:
在线演示:点击打开链接
移动&PC端的:
/*html结构:*/
<label class="switch4PC"><input id="myInputPC" type="checkbox" value="0" name="myinputPC"/><i></i></label>
/*css:*/
.switch4PC { display: inline-block; position: relative; font-size: 12px; width: 22px; height: 13px; line-height: 13px; } .switch4PC input { display: none; } .switch4PC input:checked + i:before { border-color: #3B99FC; -webkit-box-shadow: #3B99FC 0 0 0 16px inset; box-shadow: #3B99FC 0 0 0 16px inset; background-color: #3B99FC; transition: background-color .4s; -webkit-transition: background-color .4s; } .switch4PC input:checked + i:after { left: 11px; } .switch4PC i { width: 22px; height: 13px; position: absolute; z-index: 2; border: 0; background: none; outline: 0; } .switch4PC i:before { content: ''; width: 20px; height: 12px; border: 1px solid #dfdfdf; background-color: #fdfdfd; border-radius: 20px; cursor: pointer; display: inline-block; position: relative; vertical-align: top; -webkit-box-sizing: content-box; box-sizing: content-box; -webkit-box-shadow: #dfdfdf 0 0 0 0 inset; box-shadow: #dfdfdf 0 0 0 0 inset; -webkit-transition: border .4s, background-color .4s; transition: border .4s, background-color .4s; -webkit-background-clip: content-box; background-clip: content-box; } .switch4PC i:after { content: ''; width: 10px; height: 11px; position: absolute; top: 1px; left: 0; border-radius: 100%; background-color: #fff; -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); -webkit-transition: left .2s; transition: left .2s; }
仅移动&谷歌浏览器的:
/*html结构:*/
<div class="switch"><input id="myInput" type="checkbox" value="0" name="myinput"/></div>
/*css:*/
.switch { display: inline-block; position: relative; font-size: 12px; width: 22px; height: 13px; line-height: 13px; } .switch input { width: 22px; height: 13px; position: absolute; z-index: 2; border: 0; background: 0 0; -webkit-appearance: none; outline: 0; } .switch input:before { content: ''; width: 20px; height: 12px; border: 1px solid #dfdfdf; background-color: #fdfdfd; border-radius: 20px; cursor: pointer; display: inline-block; position: relative; vertical-align: top; -webkit-box-sizing: content-box; box-sizing: content-box; -webkit-box-shadow: #dfdfdf 0 0 0 0 inset; box-shadow: #dfdfdf 0 0 0 0 inset; -webkit-transition: border .4s, background-color .4s; transition: border .4s, background-color .4s; -webkit-background-clip: content-box; background-clip: content-box; } .switch input:after { content: ''; width: 10px; height: 11px; position: absolute; top: 1px; left: 0; border-radius: 100%; background-color: #fff; -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); -webkit-transition: left .2s; transition: left .2s; } .switch input:checked:before { border-color: #3B99FC; -webkit-box-shadow: #3B99FC 0 0 0 16px inset; box-shadow: #3B99FC 0 0 0 16px inset; background-color: #3B99FC; transition: background-color .4s; -webkit-transition: background-color .4s; } .switch input:checked:after { left: 11px; }
0 0
- [css]switch开关按钮,适用于移动端和IE9火狐谷歌
- css编写移动端switch开关
- 开关按钮ToggleButton和开关Switch
- 【9】ToggleButton(开关按钮)和Switch(开关)
- ToggleButton(开关按钮)和Switch(开关)的使用
- Android学习路之开关按钮ToggleButton和开关Switch
- 自定义 Switch 开关按钮
- 开关按钮Switch
- switch开关按钮
- HTML/CSS 自定义开关按钮控件(switch)样式
- css使用checkbox来打造switch开关按钮
- 纯css模仿微信switch开关按钮
- CSS兼容性技巧整理--从IE6-IE9 火狐谷歌浏览器兼容
- CSS兼容性技巧整理从IE6-IE9 火狐谷歌浏览器兼容
- CSS兼容性技巧整理--从IE6-IE9 火狐谷歌浏览器兼容
- 开关按钮ToggleButton与Switch
- 状态开关按钮ToggleButton和开关switch的功能和用法
- 状态开关按钮ToggleButton和开关switch的功能和用法
- 如何在O(1)的时间里删除单链表的结点
- 各级缓存的使用场景以及限制
- 河南第十届ACM省赛-E-八纵八横
- Java Notes (1)
- 七.shell的图形化工具。
- [css]switch开关按钮,适用于移动端和IE9火狐谷歌
- Java Notes (2)
- Java Notes (3)
- 51Nod 1179 最大的最大公约数
- 话说apm的sitl(simulation in the loop)开发环境的搭建
- Java Notes (4)
- 安卓视图树
- 资源|TensorFlow的71个使用教程与案例(资源汇总)
- 应用统计学与R语言实现学习笔记(七)——拟合优度检验