css - 如何左对齐文本但居中 fa=home 图标

标签 css bootstrap-4

我想左对齐文本,但居中对齐 fa=home icon 见下文

<div class="card" style="width:300px">
    <h4 class="card-header">Accomdation</h4>
    <div class="card-body">
    <i class="fa fa-home"; style="font-size:96px; align-content: center"></i>
    <div style="display: inline-block; text-align: left;">
    <p class="card-text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book</p>
    <a href="#" class="btn btn-primary">Learn More</a>
    </div>
  </div>

最佳答案

添加文本中心类如下:

<div class="card-body text-center"> 

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>


<div class="card" style="width:300px">
    <h4 class="card-header">Accomdation</h4>
    <div class="card-body text-center">
    <i class="fa fa-home"></i>
    <div style="display: inline-block; text-align: left;">
    <p class="card-text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book</p>
    <a href="#" class="btn btn-primary">Learn More</a>
    </div>
  </div>

关于css - 如何左对齐文本但居中 fa=home 图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52039332/

相关文章:

css - 仅使用 CSS 设置相邻选定列表项的样式

html - 通过纯 CSS 选择一对 <br> 元素中的一个

css - span 元素的垂直对齐方式

html - 使显示标题具有响应性

html - 使列高填充行 Bootstrap 4

html - Bootstrap 4 导航栏与在移动设备上不会折叠的按钮右对齐

jquery - 溢出 : hidden messing up nav-tabs

javascript - Bootstrap 4 字段在表单组内联中未正确排列

HTML/CSS : L-Shaped Cell in Table

bootstrap-4 - 使用 SASS/Gulp 将 Google 字体添加到 Bootstrap 4