【发布时间】:2018-02-05 14:55:41
【问题描述】:
我现在已经努力了好几个小时才能在引导选项卡上呈现一个完整的宽度和几行的注释字段。我想要的是这样的:
到目前为止,我所做的是寻找解决方案/帖子,但没有一个对我有用。我的剃须刀代码是:
<div class="tab-pane" id="notes">
<br />
<div class="row">
<div class="form-group">
@Html.LabelFor(model => model.Project.sysNotes, new { @class = "col-md-2 control-label" })
<div class="col-md-8">
@Html.TextAreaFor(model => model.Project.sysNotes, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Project.sysNotes, "", new { @class = "text-danger" })
</div>
</div>
</div>
<div class="row">
<div class="form-group">
@Html.LabelFor(model => model.Project.sysUser_Add, new { @class = "col-md-2 control-label" })
<div class="col-md-4">
@Html.TextBoxFor(model => model.Project.sysUser_Add, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Project.sysUser_Add, "", new { @class = "text-danger" })
</div>
@Html.LabelFor(model => model.Project.sysDD_Add, new { @class = "col-md-2 control-label" })
<div class="col-md-4">
@Html.TextBoxFor(model => model.Project.sysDD_Add, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Project.sysDD_Add, "", new { @class = "text-danger" })
</div>
</div>
</div>
我将 css 文件(bootstrap、bootstrap-sandstone 和 site)分别调整为:
textarea.form-control {
width: 100%;
height: 200px;}
和
/* Set width on the form input elements since they're 100% wide by default (LC: was 280px)*/
input,
select,
textarea {
max-width: 100%;
}
我能做什么???
也许,错误渲染是否与 _layout.cshtml 有关?
编辑(上次):我接受 T_Roy 的回答,要走的路,但最终解决我当前问题的是 Laiman 的附加组件(hack)。我仍然在我的解决方案中看到奇怪的行为,但它有效并且需要现在继续。但是,我将不得不重构并更多地了解它们是如何协同工作的。
谢谢大家!
【问题讨论】:
-
尝试将包含的 div 的类设置为
col-md-12 -
更新了解决方案,其中包含覆盖 Bootstrap MVC 表单默认 [div] 类的信息,这些类限制了对象的宽度。
标签: css asp.net twitter-bootstrap asp.net-mvc-5