Bootstrap 3: Text overlay on image

后端 未结 4 488
灰色年华
灰色年华 2020-12-08 07:02

I am using bootstrap 3 thumbnail as follows:

\"...\"
相关标签:
4条回答
  • 2020-12-08 07:39

    Is this what you're after?

    http://jsfiddle.net/dCNXU/1/

    I added :text-align:center to the div and image

    0 讨论(0)
  • 2020-12-08 07:46

    Set the position to absolute; to move the caption area in the correct position

    CSS

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

    Bootply

    0 讨论(0)
  • 2020-12-08 07:49

    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.

    0 讨论(0)
  • 2020-12-08 07:54

    try the following example. Image overlay with text on image. demo

    <div class="thumbnail">
      <img src="https://s3.amazonaws.com/discount_now_staging/uploads/ed964a11-e089-4c61-b927-9623a3fe9dcb/direct_uploader_2F50cc1daf-465f-48f0-8417-b04ac68a999d_2FN_19_jewelry.jpg" alt="..."   />
      <div class="caption post-content">  
      </div> 
      <div class="details">
        <h3>Robots!</h3>
        <p>Lorem ipsum dolor sit amet</p>   
      </div>  
    </div>
    

    css

    .post-content {
        background: rgba(0, 0, 0, 0.7) none repeat scroll 0 0;
        opacity: 0.5;
        top:0;
        left:0;
        min-width: 500px;
        min-height: 500px; 
        position: absolute;
        color: #ffffff; 
    }
    
    .thumbnail{
        position:relative;
    
    }
    .details {
        position: absolute; 
        z-index: 2; 
        top: 0;
        color: #ffffff; 
    }
    
    0 讨论(0)
提交回复
热议问题