【发布时间】:2021-10-06 21:42:03
【问题描述】:
我试图将包含<button> 的<form> 标记居中
我的视图是什么样的:
-
<p>标签和 '' 在 flex 中。 -
<p>标签垂直居中对齐 - 按钮位于底部
我尝试了什么:
-
class="align-middle"在<form>
我知道我可以设置像素下边距,但这似乎是一种草率的编码方式,因为如果我想稍后添加或删除<p>,我将不得不回来重新调整边距
<div class="d-flex align-items-center">
<p>some random text placeholder</p>
<form class="align-items-center" asp-controller="Dashboard" asp-action="Remove" asp-route-ParticipantId="@mmLeagueParticipant.child.ParticipantId" method="POST">
<button class="btn btn-outline-danger mt-5 bg-light">remove</button>
</form>
</div>
使用引导程序 4.6
【问题讨论】:
-
Bootstrap 具有
justify-content-center类,您可以将其应用于表单。 Bootstrap doc -
我试过用
<div class="justify-content-center">包围<form>,但它没有任何改变。也试过<div class="d-flex align-items-center">
标签: css bootstrap-4 margin vertical-alignment