我已经成功地将一行文本与一张图片对齐 ( 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/