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

扶醉桌前 提交于 2020-01-13 10:17:38

问题


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.


回答1:


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




回答2:


Try this on your css:

.well img{
display: inline-block;
}


来源:https://stackoverflow.com/questions/26647890/how-to-place-two-image-side-by-side-into-a-div-using-bootstrap3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!