首页 前端知识 css实现更改checkbox的样式;更改checkbox选中后的背景色;更改checkbox选中后的icon

css实现更改checkbox的样式;更改checkbox选中后的背景色;更改checkbox选中后的icon

2024-09-03 02:09:34 前端知识 前端哥 652 606 我要收藏

<input class="check-input" type="checkbox">
复制
.check-input {
width: 16px;
height: 16px;
}
/* 设置默认的checkbox样式 */
input.check-input[type="checkbox"] {
-webkit-appearance: none; /* 移除默认样式 */
border: 1px solid #999;
outline: none;
border-radius: 2px;
border: 1px solid #4C4E4F;
background: #FFF;
position: relative;
}
/* 设置选中状态下的checkbox样式 */
input.check-input[type="checkbox"]:checked {
background-color: red; /* 你可以更改这个颜色为你想要的颜色 */
}
/* 显示对勾 */
#europe-collection-list input.check-input[type="checkbox"]:checked::after {
content: "";
display: block;
width: 15px;
height: 15px;
position: absolute;
background-image: url('https://files/check_d92be03b-2b9b-4819-8e5f-169818b5d9e8.svg');
background-position: center;
background-repeat: no-repeat;
background-size: contain;
}
复制

更改后的样式

转载请注明出处或者链接地址:https://www.qianduange.cn//article/17550.html
标签
checkbox
评论
还可以输入200
共0条数据,当前/页
发布的文章

安装Nodejs后,npm无法使用

2024-11-30 11:11:38

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!