[英]Center Bootstrap form-control to center of browser
Im trying to center the form control to the center of my website, but for some reason the CSS doesnt apply to the form-control, but it applies to everything else in the div... 我试图将表单控件居中放置在我网站的中心,但是由于某些原因,CSS不适用于表单控件,但它适用于div中的其他所有内容...
This my HTML: 这是我的HTML:
<div id="search">
<h2 style="color:deepskyblue">Enter battle-tag</h2>
<div class="row">
<div class="col-md-12">
@using (Html.BeginForm())
{
@Html.TextBox("profileId", null, new { @class = "form-control" }); <br />
<p style="color:red">Replace the "#" in your battle-tag with an "-"</p>
<p style="color:red"> Search is Case-Sensitive </p>
<button class="btn btn-primary" type="submit"> Find Player </button>
}
</div>
</div>
</div>
And this is my CSS: 这是我的CSS:
body {
height: 100%;
width: 100%;
}
.body-content {
padding-left: 15px;
padding-right: 15px;
}
.dl-horizontal dt {
white-space: normal;
}
input,
select,
textarea {
max-width: 280px;
}
#search{
text-align:center;
margin-top:10%;
margin-left:10%;
}
Obviously the Bootstrap.css is default, I havent touched it at all. 显然,Bootstrap.css是默认的,我完全没有碰过它。
You can centre a element by rendering it as inline-block, and set parent's text-align attribute to center. 您可以通过将元素渲染为嵌入式块来居中,然后将父级的text-align属性设置为居中。
<div style="text-align:center;">
<div style="display:inline-block;">This should be in the middle</div>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.