css - 垂直居中按钮
问题描述
我试图将<form>
包含<button>
我的视图是什么样的:
<p>
tag 和 '' 在 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
解决方案
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-v4-rtl/4.6.0-2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="d-flex justify-content-center align-items-center">
<span class="d-flex align-items-center">some random text placeholder</span>
<form class="" asp-controller="Dashboard" asp-action="Remove" asp-route-ParticipantId="@mmLeagueParticipant.child.ParticipantId" method="POST">
<button class="btn btn-outline-danger bg-light">remove</button>
</form>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-v4-rtl/4.6.0-2/js/bootstrap.min.js"></script>
推荐阅读
- javascript - 如何按这些字符串的一部分对字符串进行排序?
- java - Java - 如何配置 log4j2.xml
- javascript - 如何使用用户支付的相同按钮将所选选项提交到 mysql
- monitoring - 避免在 Prometheus 中抓取重复/克隆/主从目标?
- javascript - 通过调用函数修复 Javascript 堆内存不足的奥秘
- flutter - Dart - 如何将函数作为参数传递
- sql - 如果存在更新,则查询从表中获取更新的记录,否则获取新记录
- php - 如何在 mysql 中建立数据库关系并使用 eloquent 和 join
- java - Maven 强制依赖项使用 Spring Boot 低版本
- javascript - 为什么我的文本输入字段被锁定以进行编辑?