我可以对复选框字段的样式使用一些帮助。现在,我自己做了一些自定义的CSS,并且效果很好。现在,我只需要在复选框窗口内打勾即可。
到目前为止的代码:
input[type=checkbox] {
-webkit-appearance: none;
appearance: none;
width: 30px; /*Desired width*/
height: 30px; /*Desired height*/
cursor: pointer;
border: 1px solid #CCC;
border-radius: 2px;
background-color: #fcfbfb;
display: inline-block;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.05);
color: black;
box-sizing: content-box;
}
input[type="checkbox"]:checked {
background-color: #002B45;
border-radius: 2px;
border: 1px solid #CCC;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.05);
color: black;
cursor: pointer;
}
input[type="checkbox"]:focus {
outline: 0 none;
border-radius: 2px;
box-shadow: none;
}
Run Code Online (Sandbox Code Playgroud)
HTML代码:
<div class="column small-12">
<div class="checkbox">
@Html.CheckBoxFor(m => m.RememberMe, new { @class = "sbw_checkbox" })
@Html.LabelFor(m => m.RememberMe, new { @class = "sbw_label" })
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
做了一些图片,以便您可以看到它的外观..以及我要达到的目标。
这是未检查的时间。
这是其检查时。
这就是我要创建的。
可以看到任何东西,或者可以尝试吗?
您可以尝试使用添加一些样式:before
input[type="checkbox"]:checked:before {
content: '';
background: #002B45;
position: absolute;
width: 15px;
height: 15px;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
Run Code Online (Sandbox Code Playgroud)
确保还添加position: relative到input[type="checkbox"]:checked样式,以便它在复选框内居中。
这是一个工作小提琴。