将CheckBox和Label放在同一行MVC上

编程入门 行业动态 更新时间:2024-10-10 13:13:54
本文介绍了将CheckBox和Label放在同一行MVC上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经搜索了论坛,并尝试了许多选项,但仍然无法使用。 如前所述,我正在尝试将我的标签和复选框放在同一行。

I've searched the forums and have tried many options but I still can't get this to work. As stated I'm trying to get my Label and Checkbox on the same line.

HTML

<div class="row"> <div class="col"> <div class="editor"> @Html.LabelFor(model => model.Gen_Print_Due_Before_Run) @Html.CheckBoxFor(model => model.Gen_Print_Due_Before_Run) @Html.ValidationMessageFor(model => model.Gen_Print_Due_Before_Run) </div> </div> </div>

CSS

.row { overflow: hidden; padding: 10px; } .col { float: left; width: 50% } .editor label { float: left; width: 30px; text-align: right; } .editor input[type="checkbox"] { width: 80px; margin: 0 0 0 10px; }

推荐答案

就像Paulie_D所说,浮动复选框。要么使用display:inline; 确保使用clear:both;在html下面,以确保它们不会浮动在其他任何元素的上方。

like Paulie_D said, float the check box. Either that or use display:inline; make sure to use clear:both; under the html to ensure they don't float over the top of any other elements.

更多推荐

将CheckBox和Label放在同一行MVC上

本文发布于:2023-07-09 10:38:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1085668.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:放在   CheckBox   Label   MVC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!