Asp.net mvc asp.net mvc剃须刀滑动复选框无法点击检查
我在asp.net mvc项目中的视图有问题。我在此视图中添加了新的checkboxFor元素:Asp.net mvc asp.net mvc剃须刀滑动复选框无法点击检查,asp.net-mvc,razor,bootstrap-4,Asp.net Mvc,Razor,Bootstrap 4,我在asp.net mvc项目中的视图有问题。我在此视图中添加了新的checkboxFor元素: <div class="col-md-6"> <div class="form-group"> <div class="checkbox clip-check check-primary"> @Html.CheckBoxFor(x => x.IsHomePage) <label for=
<div class="col-md-6">
<div class="form-group">
<div class="checkbox clip-check check-primary">
@Html.CheckBoxFor(x => x.IsHomePage)
<label for="isHomePage">
Is Home Page
</label>
</div>
</div>
</div>
但在构建并从浏览器中检查之后,我无法点击复选框来选中此复选框,即使我也成功地选中了其他复选框。我正在使用引导。非常感谢您的帮助,谢谢。
我刚刚仔细检查了您的css,您为label元素编写了所有内容。您已经隐藏了复选框输入,并通过css绘制了矩形。请参阅此代码:
.clip-check label {
cursor: pointer;
display: inline-block;
font-size: 13px;
margin-right: 15px;
padding-left: 30px !important;
position: relative;
line-height: 23px;
transition: border 0.2s linear 0s, color 0.2s linear 0s;
white-space: nowrap;
}
.clip-check label:before {
background-color: #ffffff;
border: 1px solid #c8c7cc;
content: "";
display: inline-block;
height: 20px;
left: 0;
margin-right: 10px;
position: absolute;
width: 20px;
border-radius: 0;
top: 1px;
transition: border 0.2s linear 0s, color 0.2s linear 0s;
}
.clip-check label:after {
display: inline-block;
font-size: 11px;
height: 19px;
left: 4px;
position: absolute;
top: -1px;
transition: border 0.2s linear 0s, color 0.2s linear 0s;
width: 19px;
}
因此,如果您的标签没有精确指向Id为IsHomePage
(将从asp.net服务器呈现的内容)的复选框,则样式将不会更改:after
。所以你的问题是:
<label for="isHomePage">
请将
iHomePage
更改为iHomePage
,因为您的字段名是iHomePage。我刚刚仔细检查了您的css,您为label元素编写了所有内容。您已经隐藏了复选框输入,并通过css绘制了矩形。请参阅此代码:
.clip-check label {
cursor: pointer;
display: inline-block;
font-size: 13px;
margin-right: 15px;
padding-left: 30px !important;
position: relative;
line-height: 23px;
transition: border 0.2s linear 0s, color 0.2s linear 0s;
white-space: nowrap;
}
.clip-check label:before {
background-color: #ffffff;
border: 1px solid #c8c7cc;
content: "";
display: inline-block;
height: 20px;
left: 0;
margin-right: 10px;
position: absolute;
width: 20px;
border-radius: 0;
top: 1px;
transition: border 0.2s linear 0s, color 0.2s linear 0s;
}
.clip-check label:after {
display: inline-block;
font-size: 11px;
height: 19px;
left: 4px;
position: absolute;
top: -1px;
transition: border 0.2s linear 0s, color 0.2s linear 0s;
width: 19px;
}
因此,如果您的标签没有精确指向Id为IsHomePage
(将从asp.net服务器呈现的内容)的复选框,则样式将不会更改:after
。所以你的问题是:
<label for="isHomePage">
请将
iHomePage
更改为iHomePage
,因为您的字段名是iHomePage。我不明白您所说的“但在构建并从浏览器检查后,我无法点击以选中此复选框”是什么意思。你的意思是点击标签不会切换复选框吗?哪个复选框在切换状态(选中/未选中)时遇到问题?还有其他方法可以“选中”复选框而不是在框内单击吗?@GeorgPatscheider:是的,我的意思是在浏览器中单击复选框。我不明白你所说的“但在构建并从浏览器中选中复选框后,我无法点击以选中此复选框”。你的意思是点击标签不会切换复选框吗?哪个复选框在切换状态(选中/未选中)时遇到问题?还有其他方法可以“选中”复选框而不是在框内单击吗?@GeorgPatscheider:是的,我的意思是在浏览器中单击复选框