【发布时间】:2019-05-21 17:26:54
【问题描述】:
我正在尝试将 Bootstrap 4.1 的 align-middle 应用到 row 内的 col。但它里面的内容似乎与顶部保持一致。这是我的代码:
<body class="d-flex">
<div class="container-fluid">
<a class="my-container" href="#">
<div class="row">
<div class="col flex-grow-1">
Line 1<br>Line 2<br>Line 3
</div>
<div class="col-auto text-right align-middle">
<i class="fas fa-chevron-right"></i>
</div>
</div>
</a>
</div>
</body>
这是一个显示结果的sn-p:
<link href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<body class="d-flex">
<div class="container-fluid">
<a class="my-container" href="#">
<div class="row">
<div class="col flex-grow-1">
Line 1<br>Line 2<br>Line 3
</div>
<div class="col-auto text-right align-middle">
<i class="fas fa-chevron-right"></i>
</div>
</div>
</a>
</div>
</body>
如何正确对齐图标?
【问题讨论】:
-
你能把你的css代码也发过来吗?
-
@Comé 没有自定义 CSS 代码。这都是 Bootstrap(和一个 Font Awesome 图标)。我自己的
my-container类没有附加任何样式。 -
没问题。请看下面的答案。让我知道它是否对您有用,或者您是否仍需要帮助。
标签: html css bootstrap-4 vertical-alignment