ASP.Net MVC Helper 打破 Zurb 基础
ASP.Net MVC Helper Breaks Foundation Zurb
我对 MVC 助手 CheckboxFor 有一个问题。
我发现生成的 HTML 代码创建了一个隐藏字段,这破坏了 foundation zurb 上的样式。
我在视图上使用这个助手:
@Html.CheckBoxFor(model => model.Client.Contact.IsLocked)
@Html.LabelFor(model => model.Client.Contact.IsLocked)
生成的代码是这个:
<input data-val="true" data-val-required="The Is Locked field is required." id="Client_IsLocked" name="Client.IsLocked" type="checkbox" value="true"><input name="Client.IsLocked" type="hidden" value="false">
<label or="Client_IsLocked">Is Locked</label>
看起来是隐藏字段导致标签未与复选框对齐。
有什么建议吗?
我找到了问题的答案。
原因是因为foundation的css的checkbox和label的选择器,没有包含hidden field的选择器。
快速修复,只需将此选择器添加到项目的 css 文件中:
input[type="checkbox"] + input[type="hidden"] + label,
input[type="radio"] + input[type="hidden"] + label {
display: inline-block !important;
}
我对 MVC 助手 CheckboxFor 有一个问题。 我发现生成的 HTML 代码创建了一个隐藏字段,这破坏了 foundation zurb 上的样式。
我在视图上使用这个助手:
@Html.CheckBoxFor(model => model.Client.Contact.IsLocked)
@Html.LabelFor(model => model.Client.Contact.IsLocked)
生成的代码是这个:
<input data-val="true" data-val-required="The Is Locked field is required." id="Client_IsLocked" name="Client.IsLocked" type="checkbox" value="true"><input name="Client.IsLocked" type="hidden" value="false">
<label or="Client_IsLocked">Is Locked</label>
看起来是隐藏字段导致标签未与复选框对齐。 有什么建议吗?
我找到了问题的答案。 原因是因为foundation的css的checkbox和label的选择器,没有包含hidden field的选择器。 快速修复,只需将此选择器添加到项目的 css 文件中:
input[type="checkbox"] + input[type="hidden"] + label,
input[type="radio"] + input[type="hidden"] + label {
display: inline-block !important;
}