Jes*_*Sam 0 html css twitter-bootstrap bootstrap-4
我正在尝试使用Bootstrap 4的对齐帮助器类在div中垂直对齐内容“ ABC Company”。但无法做到。我正在使用以下代码。
<div class="container" style="width: 740px;">
<div class="row">
<div class="col-sm text-right" style="line-height: 20px; height: 20px; color:#004990; text-decoration:none; font-family:Helvetica, Arial, sans-serif; font-size:10px;">
Your Account
</div>
</div>
<div class="row">
<div class="col-sm text-center" style="background-color:#0471AF; height:100px;">
<span class="align-middle">ABC Company</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
请指出我想念的是什么!
设置display: flex; justify-content: center; align-items: center;为col-sm text-center 或,或者设置display: flex; justify-content: center;为col-sm text-center和align-self: center;的<span>。
.col-sm.text-center {
display: flex;
justify-content: center;
align-items: center;
}Run Code Online (Sandbox Code Playgroud)
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<style>
</style>
<div class="row">
<div class="col-sm text-right" style="line-height: 20px; height: 20px; color:#004990; text-decoration:none; font-family:Helvetica, Arial, sans-serif; font-size:10px;">
Your Account
</div>
</div>
<div class="row">
<div class="col-sm text-center" style="background-color:#0471AF; height:100px;">
<span class="align-middle">ABC Company</span>
</div>
</div>Run Code Online (Sandbox Code Playgroud)