作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我可以在复选框字段的样式方面使用一些帮助。现在,我自己制作了一些自定义 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;
}
<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>
最佳答案
您可以尝试使用 :before
添加一些样式
input[type="checkbox"]:checked:before {
content: '';
background: #002B45;
position: absolute;
width: 15px;
height: 15px;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
position: relative
到
input[type="checkbox"]:checked
样式,以便它将在复选框内居中。
关于css - 样式复选框,在窗口内将选中的背景颜色设置为 70%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34533194/
我是一名优秀的程序员,十分优秀!