Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place two image side by side into a div using bootstrap3?

i want to place two image side by side into a div where both images are center into parent div. i am using bootstrap 3. plz help

here is my markup:

    <div class="well text-center">
        <span>Sister Properties:</span>
            <a href="#"><img src="img/innlogo.png" class="img-responsive" alt="inn_logo" /></a> <a href="#" ><img src="img/cclogo.png" class="img-responsive" alt="ccs_logo" /></a>
    </div>

I cant do this using "row-column" div but i want to do it using "well" div.

like image 290
Xubayer pantho Avatar asked Oct 30 '14 08:10

Xubayer pantho


People also ask

How do I put multiple images in a div?

Approach: First, create the <div> tag as mentioned in the previous example and insert multiple images inside a common <div> tag so that all the images have a separate <div> tag and a class name.

How do I center images side by side in HTML?

Step 1: Wrap the image in a div element. Step 2: Set the display property to "flex," which tells the browser that the div is the parent container and the image is a flex item. Step 3: Set the justify-content property to "center." Step 4: Set the width of the image to a fixed length value.


2 Answers

Your img-responsive responsive class gives your images a display:block that prevents them from centering; try removing it. Also, in order for them to be placed side by side make use of Bootstrap's grid system. You can read more about it here: http://getbootstrap.com/css/#grid.

Here is how you could do this:

<div class="well text-center">
    <span>Sister Properties:</span>
    <div class="col-md-6">
        <a href="#"><img src="img/innlogo.png" alt="inn_logo" /></a>
    </div>
    <div class="col-md-6">
        <a href="#" ><img src="img/cclogo.png" alt="ccs_logo" /></a>
    </div>
</div>

You can play with it here: http://www.bootply.com/YSlrhJHBls

EDIT: To make the top text center add a 12 wide col. To ensure the images are inside the well too, wrap them inside a div with class row as follows:

<div class="well text-center">
    <div class="col-md-12">Sister Properties:</div>
    <div class="row">
        <div class="col-md-6">
            <a href="#"><img src="http://lorempixel.com/400/200/" alt="inn_logo"></a>
        </div>
        <div class="col-md-6">
            <a href="#"><img src="http://lorempixel.com/g/400/200/" alt="ccs_logo"></a>
        </div>
    </div>
</div>

Here is the updated bootply: http://www.bootply.com/TuXAsykG7e

like image 162
benomatis Avatar answered Nov 15 '22 03:11

benomatis


Try this on your css:

.well img{
display: inline-block;
}
like image 38
batMask Avatar answered Nov 15 '22 03:11

batMask