Jan*_*zen 0 html css twitter-bootstrap bootstrap-4
我想实现一个非常简单的目标:我有一行-文本左对齐,按钮右对齐。我希望文本与按钮的标签垂直对齐。我尝试使用填充,边距等功能,但是没有任何效果。我相信我缺少一个简单而智能的解决方案。
柱塞演示:
https://plnkr.co/edit/KwRF2uOmKc3aPFQW9DXn?p=preview
<div>
<span>
This text should match the "Submit" text
</span>
<button type="button" class="btn btn-secondary float-right">Submit</button>
</div>
Run Code Online (Sandbox Code Playgroud)
感谢您的回答。
小智 6
Bootstrap 4基于flexbox,因此已经具有用于应用这些对齐实用程序的类。d-flex使容器成为伸缩容器,并align-items-center进行垂直对齐。尝试类似:
<div class="d-flex align-items-center">
<span>
This text should match the "Submit" text
</span>
<button type="button" class="btn btn-secondary ml-auto">Submit</button>
</div>
Run Code Online (Sandbox Code Playgroud)