Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3: Text overlay on image

I am using bootstrap 3 thumbnail as follows:

<div class="thumbnail">     <img src="/img/robot.jpg" alt="..." />     <div class="caption post-content">         <h3>Robots!</h3>         <p>Lorem ipsum dolor sit amet</p>      </div> </div> 

I want the caption to overlay on image but the way being done on Mashable.com

I have tried following but no luck :((

.post-content {     background: none repeat scroll 0 0 #FFFFFF;     opacity: 0.5;     margin: -54px 20px 12px;      position: relative; } 

How can I overlay a caption div on top of the image but just like (Mashable.com)?

This works but I want it centered just like Mashable. and centered for every image. for some images, it is not centered.

like image 415
DarthVader Avatar asked Sep 05 '13 08:09

DarthVader


People also ask

How do I overlay text on an image in bootstrap?

Add class=carousel-caption to the HTML tag which contains your text which needs to be positioned over your image !. (And then if you wish add custom css top:xyz% to your . carousel-caption class in css stylesheet to make it align vertically at middle.)

How do I overlay images in bootstrap?

Image Overlay: Image overlay generally refers to the image being a background image and inserting texts, and links inside of that image. It can be done using the 'card-img-overlay' property that is present in bootstrap. Also, we can do it with normal CSS along with a bootstrap theme.

How do I put text onto a picture?

On the Insert tab, in the Text group, click Text Box, click anywhere near the picture, and then type your text. To change the font or style of the text, highlight the text, right-click it, and then select the text formatting you want on the shortcut menu.

How do I put text over an image in a div in HTML?

CSS position property is used to set the position of text over an image. This can be done by enclosing the image and text in an HTML “div”. Then make the position of div “relative” and that of text “absolute”. The absolute elements are positioned relative to their parent (div).


1 Answers

You need to set the thumbnail class to position relative then the post-content to absolute.

Check this fiddle

.post-content {     top:0;     left:0;     position: absolute; }  .thumbnail{     position:relative;  } 

Giving it top and left 0 will make it appear in the top left corner.

like image 126
Will Avatar answered Oct 11 '22 01:10

Will