博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
css3美化复选框checkbox
阅读量:4654 次
发布时间:2019-06-09

本文共 2468 字,大约阅读时间需要 8 分钟。

 两种美化效果如下图:

代码(html)

1 
2

使用CSS3美化复选框checkbox

3
4
5

1. 勾选

6
7
8
9
10
11
12

2. 移动端开关

13
14
15
16
17

 

代码(css)

1 .demo{
width:560px;margin:30px auto 10px auto} 2 .wrap{
margin:30px 0} 3 .wrap p{
padding:10px 0} 4 .chk_1,.chk_2{
display:none;} 5 .top_title{
text-align:center;} 6 7 /*css3选择器:E+F 毗邻元素选择器,匹配所有紧随E元素之后的同级元素F*/ 8 9 /*******STYLE 1*******/10 .chk_1 + label {11 background-color:#FFF;12 border:1px solid #C1CACA;13 box-shadow:0 1px 2px rgba(0, 0, 0, 0.05), inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05);14 padding:9px;15 border-radius:5px;16 display:inline-block;17 position:relative;18 margin-right:30px;19 }20 .chk_1 + label:active {21 box-shadow:0 1px 2px rgba(0,0,0,0.05), inset 0px 1px 3px rgba(0,0,0,0.1);22 }23 .chk_1:checked + label {24 background-color:#ECF2F7;25 border:1px solid #92A1AC;26 color:#243441;27 }28 .chk_1:checked + label:after {29 content:'\2714';30 position:absolute;top:-8px;left:0px;31 color:#758794;32 width:100%;33 text-align:center;34 font-size:20px;35 padding:1px 0 0 0;36 vertical-align:text-top;37 }38 39 40 /*******STYLE 2*******/41 .chk_2 + label {42 width:40px;height:15px;background:#ddd;43 padding:9px;44 border-radius:20px;45 display:inline-block;46 position:relative;47 }48 .chk_2 + label:before {49 content:' ';50 width:31px;height:31px;background:#fff;51 position:absolute;top:1px;left:1px;52 z-index:999;53 border-radius:100px;54 box-shadow:0 3px 1px rgba(0,0,0,0.05), 0 0px 1px rgba(0,0,0,0.3);55 transition:all 0.1s ease-in;56 -webkit-transition:all 0.1s ease-in;57 }58 .chk_2 + label:after {59 content:' ';60 position:absolute;top:0;left:0;61 width:100%;height:100%;62 border-radius:50px;63 box-shadow:inset 0 0 0 0 #eee, 0 0 1px rgba(0,0,0,0.4);64 transition:all 0.1s ease-in;65 -webkit-transition:all 0.1s ease-in;66 }67 .chk_2:checked + label:before {68 left:26px;69 }70 .chk_2:checked + label:after {71 background:#4cda60;72 box-shadow:0 0 1px #4cda60;73 }
View Code

 

转载于:https://www.cnblogs.com/k11590823/p/5245767.html

你可能感兴趣的文章
C语言中字符串的创建
查看>>
[转载]C#深入分析委托与事件
查看>>
[ log4j ]-日志文件的使用
查看>>
CEF3开发者系列之进程和线程
查看>>
.2-浅析webpack源码之打包后文件
查看>>
SQLServer 2008以上误操作数据库恢复方法——日志尾部备份
查看>>
html如何绑定radio控件和label控件
查看>>
Java中的泛型
查看>>
PHP的类自动加载机制
查看>>
常用排序算法的总结以及编码(Java实现)
查看>>
MySQL
查看>>
HTTP/2 和 Websocket
查看>>
hdu 2050 折线分割平面
查看>>
[翻译svg教程]svg 中的g元素
查看>>
普通类中能不能有函数模板?/有函数模板的类可以是普通类吗
查看>>
表单输入绑定
查看>>
python学习日记(迭代器、生成器)-乱七八糟
查看>>
ADO.NET数据集的工作原理
查看>>
oracle实现自增长列
查看>>
自我介绍
查看>>