首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在图像旁边对齐多行文本而不将其包装在图像下面?

如何在图像旁边对齐多行文本而不将其包装在图像下面?
EN

Stack Overflow用户
提问于 2016-02-26 23:12:00
回答 4查看 3.7K关注 0票数 4

我已经成功地将一行文本与图像(小提琴)对齐。

代码语言:javascript
复制
<div class="profile-details-wrapper">
  <img class="profile-picture" src="http://placehold.it/50x50" />
  <span class="profile-details">
    username
  </span>
</div>

但是,当我尝试添加另一行文本时,它会被包装在图像(小提琴)下面。

代码语言:javascript
复制
<div class="profile-details-wrapper">
  <img class="profile-picture" src="http://placehold.it/50x50" />
  <span class="profile-details">
    username
    <br />
    username
  </span>
</div>

怎样才能有多行文本超过它旁边的图像高度,但没有包装在它下面?

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

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2016-02-26 23:30:29

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

代码语言:javascript
复制
.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; }
代码语言:javascript
复制
<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>

票数 5
EN

Stack Overflow用户

发布于 2016-02-26 23:18:19

代码语言:javascript
复制
img {
  float:left;
  margin-top: 5px;
  margin-right: 15px;
  margin-bottom: 15px;
}

p {
  display: table-cell;
  width: 400px;
}
代码语言:javascript
复制
<div class="profile-details-wrapper">
  <img class="profile-picture" src="http://placehold.it/50x50" />
  <span class="profile-details">
<p>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 </p>
  </span>
</div>

票数 4
EN

Stack Overflow用户

发布于 2016-02-26 23:21:40

给图片和描述提供一个float: left;标记如何?我不知道这是否会给你的网站带来麻烦,但那样的话,它就会把所有的文字都放在左边。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35663419

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档