【发布时间】:2017-06-27 00:00:43
【问题描述】:
我正在尝试使用引导框架(Bootstrap 4 alpha)制作应用登录页面。在尝试对齐中心的所有内容时,我在 jumbotron id 中使用了text-align:center。除电子邮件表单外的所有内容均已对齐。
有没有办法让电子邮件表单居中对齐,同时确保无论网页宽度如何,它都保持居中。
这是样式表中的代码。
.jumbotron
{
background-image: url(background.jpg);
text-align: center;
margin-top: 50px;
}
这是主要代码。
<div class="jumbotron" id="jumbotron">
<h1 class="display-3">My Awesome App!</h1>
<p class="lead">This is why YOU should download this fantastic app!</p>
<hr class="m-y-2">
<p>Want to know more? Join our mailing list!</p>
<form class="form-inline" id = "emailbar">
<div class="form-group">
<label class="sr-only" for="email">Email address</label>
<div class="input-group">
<div class="input-group-addon">@</div>
<input type="email" class="form-control" id="email" placeholder="Your email">
</div>
</div>
<button type="submit" class="btn btn-primary">Sign up</button>
</form>
</div>
【问题讨论】:
-
只需将
justify-content-center类添加到<form class="form-inline">---</form> -
别忘了指明您使用的是
bootstrap 4 alpha。bootstrap 3正在使用内联块,因此可以正确显示。bootstrap 4使用display: flex,因此您需要调整计划如何证明您的项目或对齐您的内容。
标签: html css flexbox twitter-bootstrap-4