Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I align multi-line text next to an image without it wrapping underneath?

I've successfully aligned one line of text with an image (fiddle).

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

However, when I try to add another line of text, it wraps under the image (fiddle).

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

How can I have multi-line text that exceeds the height of the image next to it, but does not wrap underneath it?

Bonus question: How would I go about aligning it vertically, too?

like image 604
Dubstaphone Avatar asked Dec 18 '22 19:12

Dubstaphone


1 Answers

Building on @freestock.tk's tabular example..

.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>
like image 192
thebjorn Avatar answered Dec 21 '22 07:12

thebjorn