简单的纯css重置input单选多选按钮的样式--利用伪类

由于input单选多选的原生样式通常都不符合需求,所以在实现功能时通常都需要美化按钮

html

<input type="radio" />
<input type="checkbox" />

css

input{visibility: hidden;} // 让原生按钮不显示
input::before{
content: "";visibility: visible;display:inline-block;
width: 0.36rem;height: 0.36rem; // 设置合适的宽高
background: url(../assets/icon/nocheck_icon.png) no-repeat center; // 用自己的图片替换-这个是未选中的图片
background-size:contain; }
input:checked::before{
content: "";visibility: visible;display:inline-block;
width: 0.36rem;height: 0.36rem;
background: url(../assets/icon/checked_icon.png) no-repeat center; // 用自己的图片替换-这个是选中的图片
background-size:contain; 
}

猜你喜欢

转载自www.cnblogs.com/leiting/p/9780102.html