有没有人已经使用Font Awesome 5图标设计了复选框?
我已经在Google上搜索过了,只找到了FA-4的示例,如http://flatlogic.github.io/awesome-bootstrap-checkbox/demo/
我升级到了FA5,并用CSS伪元素实现了其他功能,但是在复选框内部无法运行。我愿意尝试其他不需要伪元素的解决方案。
提前感谢!
Fiddle-Examples:
/* Checkboxes */
.checkbox input[type="checkbox"] {
display: none;
}
.checkbox label {
padding-left: 0;
}
.checkbox label:before {
content: "";
width: 20px;
height: 20px;
display: inline-block;
vertical-align: bottom;
margin-right: 10px;
line-height: 20px;
text-align: center;
border: 1px solid #ccc;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
font-family: "FontAwesome";
}
.checkbox input[type="checkbox"]:checked+label::before {
content: "\f00c";
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="checkbox">
<input type="checkbox" id="profile_notifications" value="" checked/>
<label for="profile_notifications">
I agree
</label>
</div>
/* Checkboxes */
.checkbox {
padding-left: 10px;
padding-top: 10px;
}
.checkbox input[type="checkbox"] {
display: none;
}
.checkbox label {
padding-left: 0;
}
.checkbox label:before {
content: "";
width: 20px;
height: 20px;
display: inline-block;
vertical-align: bottom;
margin-right: 10px;
line-height: 20px;
text-align: center;
border: 1px solid #ccc;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
font-family: "Font Awesome 5 Solid";
}
.checkbox input[type="checkbox"]:checked+label::before {
font-family: "Font Awesome 5 Solid";
content: "\f00c";
}
.test {
padding-left: 10px;
padding-top: 10px;
}
.test .pseudo-element:before {
display: none;
font-family: "Font Awesome 5 Solid";
content: "\f00c";
}
<script defer src="https://use.fontawesome.com/releases/v5.0.10/js/all.js" integrity="sha384-slN8GvtUJGnv6ca26v8EzVaR9DC58QEwsIk9q1QXdCU8Yu8ck/tL/5szYlBbqmS+" crossorigin="anonymous"></script>
<script>
window.FontAwesomeConfig = {
searchPseudoElements: true
}
</script>
<div class="checkbox">
<input type="checkbox" id="profile_notifications" value="" checked/>
<label for="profile_notifications">
Doesn't work!
</label>
</div>
<div class="test">
<label class="pseudo-element">This works!</label>
</div>
display: none;
(就像你对工作元素所做的那样),但是当我们将其添加到.checkbox input[type="checkbox"]:checked+label::before
中时,它会显示得很好,但是复选框会消失,因此无法取消选中复选框,我没有解决方案。也许其他人会介入... - MBaas