【发布时间】:2019-04-17 06:06:18
【问题描述】:
我的 ASP.NET MVC 应用程序中的 Bootstrap/CSS 存在一些问题。我有一个“表单组”,左边有一个标签,右边有一个垂直的下拉列表。
我现在已经按照我想要的方式进行了设置,除了边距。目前没有。我给的利润似乎没有效果。我几乎从 YouTube 上的视频教程中得到了这个。我不明白为什么这不起作用。
我尝试了各种方法,mb-4, mt-4, my-4, ...
我在这里做错了什么?我已经检查过我使用的是 bootstrap v3.3.7。
这是我的代码:
<div class="form-group">
@Html.LabelFor(model => model.SelectedTags, htmlAttributes: new { @class = "control-label col-md-2", id = "lblSelectedTags" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.Tag1, Model.AvailableTags, htmlAttributes: new { @class = "form-control mb-4", id = "ddlTag1" })
@Html.DropDownListFor(model => model.Tag2, Model.AvailableTags, htmlAttributes: new { @class = "form-control mb-4", id = "ddlTag2" })
@Html.DropDownListFor(model => model.Tag3, Model.AvailableTags, htmlAttributes: new { @class = "form-control mb-4", id = "ddlTag3" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.FriendlyName, htmlAttributes: new { @class = "control-label col-md-2", id = "lblFriendlyName" })
<div class="col-md-10">
@Html.EditorFor(model => model.FriendlyName, new { htmlAttributes = new { @class = "form-control", id = "edrFriendlyName" } })
@Html.ValidationMessageFor(model => model.FriendlyName, "", new { @class = "text-danger" })
</div>
</div>
结果如下:
【问题讨论】:
-
引导间距仅适用于版本 4+:getbootstrap.com/docs/4.0/utilities/spacing
-
我正在使用 bootstrap 3.3.7,我已经标记了两者,因为只有 bootstrap-4 和 twitter-bootstrap-3 可用,我对此有点困惑,是否有显着差异?我已经重新标记了它。
-
是的3和4之间有显着差异:blog.templatetoaster.com/…
-
你的意思是
class = "form-control margin-bottom-lg-4"(对不起,真的是 CSS 新手) -
好的,我明白了,他们已经在 Bootstrap 4 中重命名了它。刚刚用
margin-bottom重试了它,还是一样。我已经把它包装成 div 了,但还是一样。
标签: css asp.net-mvc razor twitter-bootstrap-3