html - 文本未与顶部对齐

标签 html css sass font-awesome

The text is aligned to the bottom of the iconfont

我不知道为什么名称文本与图标字体的底部对齐。我想将文本与 div .profile-info 的顶部对齐:

html

  <div class="profile">
    <i class="profile-pic fa fa-user-circle" aria-hidden="true"></i>
    <div class="profile-info">
      <p class="name">John Doe</p>
      <p class="user-type">Admin</p>
    </div>
  </div>

CSS

.profile
  display: table
  padding: 15px

  .profile-pic
    display: table-cell
    font-size: 40px
    padding-right: 10px

  .profile-info
    display: table-cell
    .name
      margin-bottom: 0
      position: relative
    .user-type
      color: grey

最佳答案

您必须将其垂直对齐到顶部。用这个

.profile-info
    display: table-cell
    vertical-align: top

关于html - 文本未与顶部对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43666363/

相关文章:

javascript - 无法使用 forEach 循环遍历 HTMLCollection

html - 如何在相对定位的 div 中包含绝对定位的 div?

css - Objective C 中有类似 CSS Z-Index 的东西吗?

css - 在 SCSS hsla() 函数中使用 CSS 自定义属性

html - 具有相同高度的容器未从顶部对齐

jquery - 在视口(viewport)中保持固定位置的 div - 内容可滚动?

javascript - 选择以所选字符开头的特定 li 元素

具有渐变的 CSS3 背景图像纹理不起作用

css - `scan` 在 CSS 媒体查询中是什么意思?

angular - 从 src/assets/导入 scss 文件到组件 scss 文件