html - 如何从我的 Font Awesome 复选框中删除此白色背景或边框?
问题描述
我正在使用 Font Awesome 5 来设置我的复选框的样式我的问题是当我单击我的复选框时,我无法删除或隐藏白色背景或边框
/* Update default snippet color to better see the problem */
body {
background-color: black;
color: white;
}
input[type=checkbox], input[type=radio] {
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: 0;
font-family: "Font Awesome 5 Free";
font-weight: 700;
font-size: 16px;
line-height: 14px;
}
input[type=checkbox]:after, input[type=radio]:after {
content: "\f0c8";
color: #ffffff;
display: block;
border-radius: 0px;
}
input[type=checkbox]:checked:before {
position: absolute;
content: "\f14a";
color: #445867;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.1.0/css/all.css" rel="stylesheet"/>
<div id='test'>
<input type="checkbox" name="cbx">
<label for="cbx">my checkbox</label>
</div>
和要测试的 JSFiddle:https ://jsfiddle.net/fyc4bwmr/1/
解决方案
更改并从该声明块input[type=checkbox]:checked:before
中删除:input[type=checkbox]:checked:after
position: absolute
input[type=checkbox]:checked:after{
content: "\f14a";
color: #445867;
}
小提琴:
/* NEW CSS */
input[type=checkbox]:checked:after {
content: "\f14a";
color: #445867;
}
/* Update default snippet color to better see the problem */
body {
background-color: black;
color: white;
}
input[type=checkbox],
input[type=radio] {
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: 0;
font-family: "Font Awesome 5 Free";
font-weight: 700;
font-size: 16px;
line-height: 14px;
}
input[type=checkbox]:after,
input[type=radio]:after {
content: "\f0c8";
color: #ffffff;
display: block;
border-radius: 0px;
}
/* Remove */
/* input[type=checkbox]:checked:before {
position: absolute;
content: "\f14a";
color: #445867;
}*/
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.1.0/css/all.css" rel="stylesheet" />
<div id='test'>
<input type="checkbox" name="cbx">
<label for="cbx">my checkbox</label>
</div>
推荐阅读
- jquery - Jquery Ajax 不通过发布请求发送多个数据
- django - http 响应标头中的 WCDN 缓存策略
- javascript - 带有属性+数组的Json对象,如何移动数组内的属性?
- c# - 按索引循环遍历三个 List(Of T)
- netflix - Netflix 技术背景下的事件是什么?
- laravel - 在 Laravel-Excel 3.1 中具有多个工作表的 Excel 文件 -> 在单元格验证后导入原始并存储 + 存储单个工作表
- vue.js - 无法使用 vuejs v-for 在 html 中显示数组
- javascript - 如何使用 if 语句使用 JavaScript 更改 CSS?
- php - 管理面板数组到字符串的转换
- c++ - QTextEdit 没有突出显示简单的两行。我正在为 Qt 5.13 MinGw x64 使用 QRegularExpression