使用CSS3实现input多选框自定义样式的方法示例
这篇文章主要介绍了使用CSS3实现input多选框自定义样式的方法示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
原理:首先把input元素隐藏掉,然后用CSS设置label元素(其他元素也可以)的样式,选中时的样式使用input:check+label选中label,无须使用图片和JS
效果预览

html代码
男女
CSS代码
.radio { position: relative; display: inline-block; margin-right: 12px; } .radio input { width: 15px; height: 15px; appearance: none;/*清楚默认样式*/ -webkit-appearance: none; opacity: 0; outline: none; z-index: 8; /*让input层级高于label,使之能选中*/ } .radio label { position: absolute; left: 0; top: 6px; width: 15px; height: 15px; border: 1px solid #3582E9; } .radio input:checked+label::after { content: ""; position: absolute; left: 4px; top: 0px; /* 这里显示矩形的一半边框再旋转45度来实现对勾样式 */ width: 5px; height: 12px; border-right: 1px solid #000000; border-bottom: 1px solid #000000; transform: rotate(45deg); }以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持0133技术站。
标签: