Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap thumbnail caption to the right

How to make the caption of a Twitter Bootstrap thumbnail be placed to the right of the image instead of below? Preferably in CSS. So far I am just using existing tags as my css knowledge is very limited.

<ul class="thumbnails">
  <li class="span2">
    <div class="thumbnail span4">
  <div class="span2">
        <img src="http://placehold.it/120x160" alt="">
      </div>
      <div class="caption">
        <h5>Thumbnail label </h5>
        <p>Cras justo odio, dapibus ac facilisis in, egestas eget. Eget metus</p>
        <p><a href="#" class="btn btn-primary">Action</a> <a href="#" class="btn">Action</a></p>
      </div>
    </div>
  </li>
</ul>
like image 387
Rutger Karlsson Avatar asked Aug 03 '12 15:08

Rutger Karlsson


2 Answers

With a slight modification of your HTML, and the addition of a new class (right-caption), a few CSS rules should cover you.

HTML

<div class="thumbnail right-caption span4">
  <img src="http://placehold.it/120x160" alt="">
  <div class="caption">
    <h5>Thumbnail label</h5>
    <p>Cras justo odio, dapibus ac facilisis in, egestas eget. Eget metus</p>
    <p><a href="#" class="btn btn-primary">Action</a> <a href="#" class="btn">Action</a></p>
  </div>
</div>

Note: I'm taking the <img> out of the <div> you originally wrapped it in.

CSS

.thumbnail.right-caption > img {
    float: left;
    margin-right: 9px;
}

.thumbnail.right-caption {
    float: left;
}

.thumbnail.right-caption > .caption {
    padding: 4px;
}
​

Note: The margin and padding are just stylistic; floating is the key.

JSFiddle

like image 121
merv Avatar answered Nov 15 '22 06:11

merv


No additional css. Change a/span tags to div if needed

<a href="..." class="thumbnail clearfix">
  <img src="..." class="pull-left">
    <span class="caption pull-right">
    Lorem ipsum
   </span>
  </a>
like image 27
ymakux Avatar answered Nov 15 '22 06:11

ymakux