【发布时间】:2018-04-02 02:23:21
【问题描述】:
尝试垂直对齐以下卡片中的文本中心:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<div class="row text-center h-100">
<div class="col-md-3 text-center my-auto">
<div class="card card-block justify-content-center" style="height: 120px">
<div class="card-body">
This is some text within a card body.
</div>
</div>
</div>
</div>
我完全知道这里有许多类似的问题,但是我尝试了各种解决方案,但似乎没有一个对我的卡有用。
我在 parent、card 和 card-body 上尝试了“my-auto”。我试过“d-flex align-items-center h-100”和“justify-content-center”。还尝试使用显示属性。我错过了什么?
【问题讨论】:
标签: css twitter-bootstrap flexbox