Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add text over the image in bootstrap

I am noob in bootstrap and making one simple responsive web design. I had given the bootstrap container the image now i want to add text over the images, so i can add more text and images on that container. I tried on google but didn't find the exact answer. Please help

<div class="container">
    <div class="row">
        <div class="col-xs-12 col-sm-6 col-md-8 col-centered">
            <div class="maintxt">
                <img src="background.png" class="img-responsive">
            </div>
        </div>
    </div>
</div>

and here is the image, what i want - http://i.imgur.com/FAPXpFL.jpg

like image 265
Andrew Thomas Avatar asked Oct 01 '14 19:10

Andrew Thomas


People also ask

How do I add text overlay to an image?

On the Insert tab, in the Text group, click Text Box, drag to draw a text box 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 on top of an image 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”.

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.

What is overlay bootstrap?

BootstrapVue's custom b-overlay component is used to visually obscure a particular element or component and its content. It signals to the user of a state change within the element or component and can be used for creating loaders, warnings/alerts, prompts, and more.


1 Answers

I'd be inclined to put the image in place as a background:

.maintxt {
    background-image: url(images/background.png);
    background-size: cover;
}

<div class="container">
    <div class="row">
        <div class="col-xs-12 col-sm-6 col-md-8 col-centered">
            <div class="maintxt">
                My great text.
            </div>
        </div>
    </div>
</div>

If that doesn't work, you'll need to use relative and absolute positioning:

.maintxt {position: relative;}
.maintxt > img, .overlay-text {position: absolute;}

<div class="container">
    <div class="row">
        <div class="col-xs-12 col-sm-6 col-md-8 col-centered">
            <div class="maintxt">
                <img src="background.png" class="img-responsive">
                <span class="overlay-text">My super text.</span>
            </div>
        </div>
    </div>
</div>

Demo

like image 94
isherwood Avatar answered Sep 28 '22 19:09

isherwood