加入收藏 | 设为首页 | 会员中心 | 我要投稿 焦作站长网 (https://www.0391zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 系统 > 正文

CSS3美化表单控件全集

发布时间:2020-03-13 21:27:35 所属栏目:系统 来源:站长网
导读:这篇文章主要为大家详细介绍了CSS3美化表单控件的技巧,美化下拉控件、单选框、复选框,感兴趣的小伙伴们可以参考一下

二.美化单选框
 
lable标签可以通过for属性与单选框实现联动。我们利用这一特性来实现美化单选框,这也是原理所在。还有就是别忘了将真正的单选框(type="radio")隐藏掉。

CSS Code复制内容到剪贴板

/*用过label标签来模拟radio 的样式*/  

.radio-block label{   

    displayinline-block;   

    positionrelative;   

    width28px;   

    height28px;   

    border1px solid #cccccc;   

    background-color#fff;   

    border-radius: 28px;   

    cursorpointer;   

    margin-right:10px;   

}   

  

input[type="radio"]{   

    displaynone;   

}   

.radio-block label:after{   

    content'';   

    displayblock;   

    positionabsolute;   

    width20px;   

    height20px;   

    left4px;   

    top4px;   

    background-color#28bd12;   

    border-radius: 20px;   

    /*通过scale属性来控制中心点*/  

    -webkit-transform: scale(0);   

    transform: scale(0);   

}   

/*选中样式*/  

input[type="radio"]:checked + label{   

    background-color :#eee;   

    -webkit-transition: background-color .3s ease-in;   

    transition: background-color .3s ease-in;   

}   

/*选中之后的样式*/  

input[type="radio"]:checked + label:after{   

    -webkit-transform: scale(1);   

    transform: scale(1);   

    -webkit-transition: transform .2s ease-in;   

    transition: transform .2s ease-in;   

}    

  

最后效果:

CSS3美化表单控件全集

三.美化复选框

CSS3美化表单控件全集

原理和单选框的制作方式类似。在checked的时候该表圆形的left值和label的背景。

CSS Code复制内容到剪贴板

.switch-block{   

    width980px;   

    padding: 3% 0;   

    margin: 0 auto;   

    text-aligncenter;   

    background-color#fc9;   

}   

.switch-block label{   

    displayinline-block;   

    width62px;   

    height30px;   

    background-color:#fafafa;   

    border:1px solid #eee;   

    border-radius: 16px;   

    positionrelative;   

    margin-right10px;   

    cursorpointer;   

    -webkit-transition: background .2s ease-in;   

    transition :background .2s ease-in;   

}   

input[type="checkbox"]{   

    displaynone;   

}   

.switch-block label:after{   

    content'';   

    positionabsolute;   

    width28px;   

    height28px;   

    border1px solid #eee;   

    border-radius: 14px;   

    left1px;   

    background-color:#fff;   

    -webkit-transition: left .2s ease-in;   

    transition: left .2s ease-in;   

}   

.switch-block input[type="checkbox"]:checked + label{   

    background-color:#3c6;   

    -webkit-transition: background .2s ease-in;   

    transition :background .2s ease-in;   

}   

.switch-block input[type="checkbox"]:checked + label:after{   

    left32px;   

    -webkit-transition: left .2s ease-in;   

    transition: left .2s ease-in;   

(编辑:焦作站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读