css - images to the center of the div in bootstrap -


all images should center aligned irrespective size. have tried below code, doesn't work me. appreciated

.border-class{    border:1px solid #ddd;    padding:5px;    min-height:160px;  }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>  <div class="container">   <div class="col-xs-3">      <div class="border-class">    <img src="http://www.w3schools.com/bootstrap/cinqueterre.jpg" class="img-responsive" alt="cinque terre"/>        </div>  </div>  <div class="col-xs-3">       <div class="border-class">    <img src="https://cdn2.iconfinder.com/data/icons/hawcons-gesture-stroke/32/icon_27_one_finger_click-128.png" class="img-responsive" alt="cinque terre"/>       </div>  </div>  <div class="col-xs-3">       <div class="border-class">    <img src="http://www.w3schools.com/bootstrap/cinqueterre.jpg" class="img-responsive" alt="cinque terre"/>       </div>  </div>  <div class="col-xs-3">     <div class="border-class">    <img src="http://www.w3schools.com/images/colorpicker.png" class="img-responsive" alt="cinque terre"/>       </div>  </div>  </div>

you can use css flexbox. add flex properties .border-class

.border-class {   display: flex;   justify-content: center;   align-items: center; } 

see snippet below:

.border-class{    /* add these 'flex' properties */    display: flex;    justify-content: center;    align-items: center;    border:1px solid #ddd;    padding:5px;    min-height:160px;  }
<!doctype html>  <html>  <head>    <meta name="viewport" content="width=device-width, initial-scale=1">    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>  </head>  <body>    <div class="container">   <div class="col-xs-3">      <div class="border-class">    <img src="http://www.w3schools.com/bootstrap/cinqueterre.jpg" class="img-responsive" alt="cinque terre"/>        </div>  </div>  <div class="col-xs-3">       <div class="border-class">    <img src="https://cdn2.iconfinder.com/data/icons/hawcons-gesture-stroke/32/icon_27_one_finger_click-128.png" class="img-responsive" alt="cinque terre"/>       </div>  </div>  <div class="col-xs-3">       <div class="border-class">    <img src="http://www.w3schools.com/bootstrap/cinqueterre.jpg" class="img-responsive" alt="cinque terre"/>       </div>  </div>  <div class="col-xs-3">     <div class="border-class">    <img src="http://www.w3schools.com/images/colorpicker.png" class="img-responsive" alt="cinque terre"/>       </div>  </div>  </div>    </body>  </html>

hope helps!


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -