【发布时间】:2019-10-07 10:49:14
【问题描述】:
我们需要提供两个内联 div,第一个 div 应该在左边,第二个 div 应该在同一行的中心。
<div style="margin-top:200px;">
<div align="left" style="display:inline;">
<label>Restrict to Primary Location:</label>
@(Html.Kendo().DropDownList()
.Name("ddl_restictToPrimaryLoc")
.DataTextField("Text")
.DataValueField("Value")
//.Events(e => e.Change("restictToPrimaryLocChange"))
.BindTo(new List<SelectListItem>() {
new SelectListItem() {
Text = "Yes",
Value = "1"
},
new SelectListItem() {
Text = "No",
Value = "0"
}})
.Value("1")
.HtmlAttributes(new { style = "width: 5%", @class = "form-control" }))
</div>
<div align="center" style="display:inline;">
<button type="button" value="button" id="btn_AddSelection" class="jqButton margin-bottom10">Add Selection</button>
</div>
</div>
它以两个 div 左对齐的状态显示 UI。
请提出建议。
【问题讨论】:
-
是否有必要使用 display:inline,因为 display:inline 元素不会占用宽度,所以不能居中 - 内联元素将接受边距和填充,但元素仍然像你可能的那样内联预计。边距和内边距只会将其他元素水平推开,而不是垂直推开。
标签: jquery html css styles text-align