html - 如何在图像旁边对齐多行文本而不将其换行?

标签 html css twitter-bootstrap twitter-bootstrap-4 bootstrap-4

我已经成功地将一行文本与一张图片对齐 ( fiddle )。

<div class="profile-details-wrapper">
  <img class="profile-picture" src="http://placehold.it/50x50" />
  <span class="profile-details">
    username
  </span>
</div>

但是,当我尝试添加另一行文本时,它会换行到图像下方 ( fiddle )。

<div class="profile-details-wrapper">
  <img class="profile-picture" src="http://placehold.it/50x50" />
  <span class="profile-details">
    username
    <br />
    username
  </span>
</div>

我怎样才能让多行文本超出其旁边的图像高度,但又不环绕在图像下方?

额外的问题:我将如何垂直对齐它?

最佳答案

基于@freestock.tk 的表格示例..

.profile-details-wrapper { display: table-row; }
.profile-picture {
  display: table-cell; 
  vertical-align: top; 
  margin-right: 10px;
}
.profile-details { display: table-cell; vertical-align: top; }
<div class="profile-details-wrapper">
  <img class="profile-picture" src="http://placehold.it/50x50">
  <div class="profile-details">
text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here text here
  </div>
</div>

关于html - 如何在图像旁边对齐多行文本而不将其换行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35663419/

相关文章:

javascript - Bootstrap 中的 KendoGrid

twitter-bootstrap - 如何防止 Bootstrap Tooltip 崩溃?

javascript - DataTables 未使用 Bootstrap 模态正确初始化

html - 固定位置 Flexbox 和 VW 单元的跨浏览器问题

jquery - 在我的示例中从 jquery find() 获取未定义

html - 如何删除 CSS 值

javascript - 如何隐藏选择选项的旧样式版本?

html - 如何在 Bootstrap 流体布局中底部对齐网格元素

javascript - 如何使用 Javascript 或 Jquery 将一系列 JSON 数据附加到 HTML?

javascript - 在 ui.bootstrap Angular Modal 中使用 JQuery $.each 运算符将 CSS 应用于每个元素